Have you considered using async calls to the web service? In some situations, using an async model can be much less error prone and better performing than using an concurrent approach. In a lot of situations, trying to model your algorithm in an async way is just too non-intuitive so using multiple threads (typically using the threadpool is best) is a good approach. However, in this case it sounds like you've got a pretty simple model (sending pieces of data to a web service and collect the responses) which might make an async approach extremely easy.
If you're going to take a threadpool approach, you'll have to be very careful to prevent creating a deadlock potential. The only time its safe to block a threadpool thread is if you know that it isn't directly or indirectly waiting for something else that requires a threadpool thread. For example, I remember hearing something like synchronous web services calls in 1.1 use async I/O. If this is true (might have been something else similar - was just listening to a PDC session about what's been fixed in Whidbey for Web Services) it means that doing a sync. web services call on a threadpool thread could result in deadlock (although you might not notice it unless your machine is heavily loaded, or the planets align in just the right way). Rick ----- Original Message ----- From: "Paul Johansen" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, April 21, 2004 4:20 PM Subject: Multiple Threads or ThreadPool? > I need to process (take the data from each row and use it to call a > relatively slow Web service) a DataRowCollection of about 300,000 > records and would like to divide it up and multithread the processing. > > > > My initial thought was to spawn x number of threads and have them each > process a portion of the rows. I have not used the ThreadPool before, > but would adding each row to the pool with QueueUserWorkItem be a better > solution? > > > > Thanks in advance, > > > > Paul > > > =================================== > This list is hosted by DevelopMentor� http://www.develop.com > Some .NET courses you may be interested in: > > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles > http://www.develop.com/courses/gaspdotnetls > > View archives and manage your subscription(s) at http://discuss.develop.com > =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com
