Jan de Jager
Jan de Jager

Reputation: 870

Background Worker Thread in WebService context

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.

Upvotes: 1

Views: 1900

Answers (1)

Rune Grimstad
Rune Grimstad

Reputation: 36340

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.

Upvotes: 2

Related Questions