Windows service threading call to WCF service
Posted
by Sam Brinsted
on Stack Overflow
See other posts from Stack Overflow
or by Sam Brinsted
Published on 2010-04-20T10:20:46Z
Indexed on
2010/04/20
10:23 UTC
Read the original article
Hit count: 285
Hi,
I have a windows service that is reading data from a database and then submitting it to a WCF serivce. Once that has finished it is stamping a processed date on the original record.
Trouble I am currently having is to do with threading.
The call to the WCF serivce is relatively long and I want to have a number of concurrent calls to the service to help improve the throughput of the windows service.
Currently I have a submitToService method on a new worker class. Upon reading a new row from the database I am creating a new thread which is calling this method.
This obviously isn't too good as the number of threads quickly shoots up and overburdens the WCF service. I have put a thread.sleep in the submit method and am sure to call
System.Threading.Thread.CurrentThread.Abort();
after the submission has finished. However, I don't seem to see the number of threads go down. How can I just have a fixed number of threads that can be used in the windows service? I did think about using a thread pool but read somewhere that wasn't a good choice for a windows service.
Thanks very much.
© Stack Overflow or respective owner