Multi-threading in windows service created in .NET (C#)

N

.NET Developer

We have a windows service written in C# that does the following:

- Access the SQL DB to get the list of rows to be processed
- For each row talk to an external webservice by passing some of the data
from the row and get a response
- save the response in the SQL table
- Repeat this for each row.

We want to convert this into a multi-threaded windows service so that many
rows can be processed simultaneously as follows:

- Access the SQL DB to get the list of rows to be processed
- Create upto 10 threads and talk to external webservice
- Save the response in the SQL table by each thread
- if there is a failure in one thread, stop the service (but wait until all
the threads finished their processing.

We are having problem with this. Whenever the external webservice doesn't
respond the thread doesn't return with error even if we set the timeout. So
the service hangs.

If anyone has a code sample that does something similar to this I would like
to take a look at it. Or if someone can put together the pseudo code I
really appreciate but this should specifically address to windows services.

Thanks for your help.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top