Re: Web Service as a background service



"Jason Barnett" <JasonBarnett@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:B116B1DA-6BF3-43A1-8376-59B0C7267082@xxxxxxxxxxxxxxxx
I'm trying to create a Web Service that acts like a Windows Service. It
contains Start, Stop, and GetStatus methods. Invoking the Start method of
the web service should kick off a timer and the Stop method stops the timer.
I've been able to accomplish all by placing the timer in the Application
object (to persist its state). However, the timer doesn't fire since the web
method has finished executing (and the asmx file is unloaded?).

I've tried creating a seperate thread in hopes that the worker thread would
function after the web method finishes execution, but apparently that didn't
work. I suspect I would need to create a seperate process that runs in the
background, but I hope there's another way.

Could someone give some direction on a quick and easy approach, if one exists?

Yes. Use a Windows Service. Web Services aren't for this purpose, and it's not going to work.

Windows Services are trivial to create. Why not use them, since that's what they're for. If you need the service to be triggered based on a client calling the web service, then have the web service send a message to the Windows Service.

--
John Saunders | MVP - Connected System Developer

.



Relevant Pages

  • Re: streamwriter file lock (re-post)
    ... How do you know the other app will never try to run at the exact same moment as your timer? ... I'm surprised you use .NET and VB for this type of thing - I'd suggest using PERL for Web Service interaction. ... Private Sub myTimer_Elapsed ... Dim drCebos As DataRow ...
    (microsoft.public.vsnet.general)
  • Web Service (or Timer) Randomly Ending
    ... service's timer to run, the timer would log entries indefinitely until ... IIS service. ... I've now deployed the web service to a shared hosting environment (IIS ... is there an event or something I can trap to write ...
    (microsoft.public.dotnet.framework.webservices)
  • Web Service (or Timer) Randomly Ending
    ... I've built a .NET 2.0 web service and tied it into an ASP.NET 2.0 web ... service's timer to run, the timer would log entries indefinitely ... IIS service. ... is there an event or something I can trap to ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: Timeout on web service call
    ... Dim callback As System.AsyncCallback ... The web service is set to sleep for 20 seconds, but I still don't get a ... I thought a timer created a thread, ... long time for whatever reason. ...
    (microsoft.public.pocketpc.developer)
  • Why Timer stop working ?
    ... I've writed a C# windows service in VS 2003. ... of a web service. ... The timer interval is 1 sec, and each functions 'counts' his number of timer ... (i save the last clock datetime in TmrSystem_Elapsed event handler and i ...
    (microsoft.public.dotnet.languages.csharp)

Loading