views:

440

answers:

1

Ok, so i have Call1 in a webservice that will start a bacground worker thread to start doing some processing, but would like to have another call (Call2) that will monitor the original Worker Thread via a reference?

Any suggestions on how to do this? I'd really like to stay away from a WinService to do my processing. As i need it to be more realtime.

+1  A: 

I don't see why using a Service application should be a problem. Services run all the time and monitoring them can be done it real time.

But, if you really don't want to go that way then there are other options. It is possible to start a new thread, using the ThreadPool or by starting a new Thread manually, and that thread will run in the background of the application pool where your web service runs.

You may want to use a task scheduler library for this. Check out Quartz.net for this.

Be aware that the app domain where your web service runs may be killed at any time if IIS decides it is necessary, so there is no guarantee that the job will complete. Using a Service application will fix this.

Rune Grimstad
I didn't think about the app domain issue. You're right, this is not going to be save at all... How easy is it to send a direct event to the windows service instead of relying on a timer to check the DB for a new job?
Jan de Jager
If you are on .NET 3.5 you can host a web service directly in your service application using WCF. That way you can expose methods that interact with your service directly. If that isn't an option then you can use Remoting to communicate with your service application from your web service. It's not very difficult, but more clumsy than the WCF approach.
Rune Grimstad