I'd try to think of a different way to do things, rather than forcefully terminating a thread that's doing some work for you.
Your scenario sounds like you need to call a web service on the worker thread, and wait for the response. If you don't get a response back within a given timeout, then you want to stop waiting and essentially reschedule the request. If that was an accurate description of what you're trying to do, then why not just invoke the web service asynchronously? Then you don't need to do anything drastic when you get a timeout...and when the call completes you'll be able to service the response on another thread pool thread. You should be able to accomplish more total work this way, since you can have totalPendingRequests > n where n is the size of your thread pool. (discounting any protocol-specific issues, like the maximum number of HTTP connections you're allowing, etc.) Greg Reinacker Reinacker & Associates, Inc. http://www.rassoc.com http://www.rassoc.com/gregr/weblog/ -----Original Message----- From: Moderated discussion of advanced .NET topics. [mailto:ADVANCED-DOTNET@;DISCUSS.DEVELOP.COM] On Behalf Of Karim Tabbouche Sent: Tuesday, November 12, 2002 9:08 AM To: [EMAIL PROTECTED] Subject: multithreaded application Hi I am creating a multithreaded application and am having problems with implementation. Here how it should work. In the main thread I will read an xml document and for each node create a new thread using the thread pool, now this is the simple part. The problem is that I have to timeout(or kill) a thread if the thread doesn't finish it job in the timeout specified and if it doesn't then i need to recreate the thread after timeout+1 minutes and then timeout+2 up to the number of my retries and if i reach the maximum of retries and the thread doesn't finish its job then i would raise an exception for that thread. The job that the thread has to do is call a webservice method and the info about this webservice can be pulled from the database using the id attribute in the xml doc. Note that I should use the thread pool for all the worker threads. <jobs> <job retry=3 timeout=2 id=4/> <job retry=3 timeout=2 id=3/> <job retry=1 timeout=2 id=6/> <job retry=2 timeout=2 id=8/> </jobs> Thanks, Karim You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.
