Self running timer on Webservice??

Discussion in 'ASP .Net Web Services' started by Christina Haller, Feb 11, 2005.

  1. Hi
    Is it possible to do something like that:
    1. there is a file located on my website
    2. I would like to start a webservice that copies that file each 24 hours to
    a backup dir on the website
    3. The webservice should be self running (without a client connection)

    Until now, I tried the following stuff, but the timer does not run when i
    call the method starttimer! I was thinking that the modal variable mVal will
    count up on each timer_tick and the stoptimer returns then the amount of
    ticks done. But nothing comes back.

    Any idea?? Thanks

    1. Builded a webservice containing 2 Methods and 1 Timer
    Public mVal As Long

    <WebMethod()> _

    Public Function StartTimer() As String

    Timer1.Interval = 1000

    Timer1.Start()

    StartTimer = CStr(mVal)

    End Function

    <WebMethod()> _

    Public Function StopTimer() As String

    Timer1.Stop()

    StopTimer = CStr(mVal)

    End Function

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Timer1.Tick

    mVal = mVal + 1

    End Sub
    Christina Haller, Feb 11, 2005
    #1
    1. Advertising

  2. Christina Haller

    Dan Rogers Guest

    This isn't going to work. What you may want to consider is creating an NT
    service to do this - as this is more closely suited to the kinds of things
    you would choose service instead of web-service to do.

    Web services are stateless - so a call to one method won't carry over to
    the next method call. If enough time passes, the thread will time out. In
    fact, if you are just creating a normal time on a web service thread, and
    then returning, when that thread is reharvested, it's timer will get
    orphaned (and eventually croak).

    --------------------
    >From: "Christina Haller" <>
    >Subject: Self running timer on Webservice??
    >Date: Fri, 11 Feb 2005 11:47:59 +0100
    >Lines: 48
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
    >X-RFC2646: Format=Flowed; Original
    >Message-ID: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    >NNTP-Posting-Host: line-zh-102-249.adsl.econophone.ch 212.53.102.249
    >Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
    >Xref: TK2MSFTNGXA01.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webservices:5490
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >
    >Hi
    >Is it possible to do something like that:
    >1. there is a file located on my website
    >2. I would like to start a webservice that copies that file each 24 hours

    to
    >a backup dir on the website
    >3. The webservice should be self running (without a client connection)
    >
    >Until now, I tried the following stuff, but the timer does not run when i
    >call the method starttimer! I was thinking that the modal variable mVal

    will
    >count up on each timer_tick and the stoptimer returns then the amount of
    >ticks done. But nothing comes back.
    >
    >Any idea?? Thanks
    >
    >1. Builded a webservice containing 2 Methods and 1 Timer
    >Public mVal As Long
    >
    ><WebMethod()> _
    >
    >Public Function StartTimer() As String
    >
    >Timer1.Interval = 1000
    >
    >Timer1.Start()
    >
    >StartTimer = CStr(mVal)
    >
    >End Function
    >
    ><WebMethod()> _
    >
    >Public Function StopTimer() As String
    >
    >Timer1.Stop()
    >
    >StopTimer = CStr(mVal)
    >
    >End Function
    >
    >Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
    >System.EventArgs) Handles Timer1.Tick
    >
    >mVal = mVal + 1
    >
    >End Sub
    >
    >
    >
    >
    Dan Rogers, Feb 15, 2005
    #2
    1. Advertising

  3. Ok, that was what i assumed.
    Because the webserver is not mine, I cant install any software on it.
    But if found another solution for doing my (automated) backup.

    Thanks anyway.


    "Dan Rogers" <> wrote in message
    news:...
    > This isn't going to work. What you may want to consider is creating an NT
    > service to do this - as this is more closely suited to the kinds of things
    > you would choose service instead of web-service to do.
    >
    > Web services are stateless - so a call to one method won't carry over to
    > the next method call. If enough time passes, the thread will time out.
    > In
    > fact, if you are just creating a normal time on a web service thread, and
    > then returning, when that thread is reharvested, it's timer will get
    > orphaned (and eventually croak).
    >
    > --------------------
    >>From: "Christina Haller" <>
    >>Subject: Self running timer on Webservice??
    >>Date: Fri, 11 Feb 2005 11:47:59 +0100
    >>Lines: 48
    >>X-Priority: 3
    >>X-MSMail-Priority: Normal
    >>X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
    >>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
    >>X-RFC2646: Format=Flowed; Original
    >>Message-ID: <>
    >>Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    >>NNTP-Posting-Host: line-zh-102-249.adsl.econophone.ch 212.53.102.249
    >>Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
    >>Xref: TK2MSFTNGXA01.phx.gbl

    > microsoft.public.dotnet.framework.aspnet.webservices:5490
    >>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >>
    >>Hi
    >>Is it possible to do something like that:
    >>1. there is a file located on my website
    >>2. I would like to start a webservice that copies that file each 24 hours

    > to
    >>a backup dir on the website
    >>3. The webservice should be self running (without a client connection)
    >>
    >>Until now, I tried the following stuff, but the timer does not run when i
    >>call the method starttimer! I was thinking that the modal variable mVal

    > will
    >>count up on each timer_tick and the stoptimer returns then the amount of
    >>ticks done. But nothing comes back.
    >>
    >>Any idea?? Thanks
    >>
    >>1. Builded a webservice containing 2 Methods and 1 Timer
    >>Public mVal As Long
    >>
    >><WebMethod()> _
    >>
    >>Public Function StartTimer() As String
    >>
    >>Timer1.Interval = 1000
    >>
    >>Timer1.Start()
    >>
    >>StartTimer = CStr(mVal)
    >>
    >>End Function
    >>
    >><WebMethod()> _
    >>
    >>Public Function StopTimer() As String
    >>
    >>Timer1.Stop()
    >>
    >>StopTimer = CStr(mVal)
    >>
    >>End Function
    >>
    >>Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
    >>System.EventArgs) Handles Timer1.Tick
    >>
    >>mVal = mVal + 1
    >>
    >>End Sub
    >>
    >>
    >>
    >>

    >
    Christina Haller, Feb 17, 2005
    #3

  4. > What was the other solution you found? I tried creating a pair of
    > webservices that accept a target URI to "signal" every given period for
    > a given total duration. These two services pass the state info back and
    > forth in their arguments and then send a "signal" (request) to wake up
    > the main web service. While the ping-ponging works, my threads still
    > randomly die (sometimes a few minutes, sometimes after 40 minutes of
    > ping-pong
    >
    > Hopefully you found something else that works cause I am getting pretty
    > frustrated with having my threads just die.


    I could not find a solution for the webservice.After I brought down my
    Webspace Provider once :-s, I changed the approach. Instead of having a
    continuosly running service on the webserver, I create my backup of the
    database when the first user (per day) is login in to the application and
    send via email to my workplace;-). That means, if someone changes data,
    automatically the database has been saved once per day.

    That replaces my need of the webservice.

    Until now, I couldnt figure out the webservice stuff. It's really
    complicated, but I think it has to do with the asynchronous call of the
    webservice. If I find a solution, I'l post it here of course.

    cheers
    c.



    >
    >
    >
    > --
    > taliesin77
    > ------------------------------------------------------------------------
    > Posted via http://www.codecomments.com
    > ------------------------------------------------------------------------




    >
    Christina Haller, Mar 8, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ralf W. Grosse-Kunstleve
    Replies:
    16
    Views:
    578
    Lonnie Princehouse
    Jul 11, 2005
  2. Ralf W. Grosse-Kunstleve
    Replies:
    18
    Views:
    592
    Bengt Richter
    Jul 11, 2005
  3. Ralf W. Grosse-Kunstleve
    Replies:
    2
    Views:
    399
    Dan Sommers
    Jul 12, 2005
  4. falcon
    Replies:
    0
    Views:
    372
    falcon
    Jul 31, 2005
  5. Bart Kastermans
    Replies:
    6
    Views:
    401
    Bart Kastermans
    Jul 13, 2008
Loading...

Share This Page