Can anyone tell me if it's possible to use and control a fixed number of ThreadPool threads in my app? Or are ThreadPool threads more of a 'fire- and-forget' kind of scenario?
I'm building an MSMQ listener using asynchronous events to get each message, and right now I create a new thread in the thread pool to handle each message. It works ok but I realize now it's a flawed design because it simply throws each message in the ThreadPool queue and waits there instead of waiting in the MSMQ queue like it should. This is not the way to do it, obviously, and it's especially noticeable at time of shutdown, because everything's in the ThreadPool queue, and I don't know how to wait until all my threads are done to know when it's safe to shut down my app. Do I need to keep an array of threads, is that the pattern one uses for this kind of scenario? If anyone knows of a good sample code for this I'd really appreciate it. Thank you. Andy =================================== This list is hosted by DevelopMentorŪ http://www.develop.com Some .NET courses you may be interested in: Essential .NET: building applications and components with CSharp August 30 - September 3, in Los Angeles http://www.develop.com/courses/edotnet View archives and manage your subscription(s) at http://discuss.develop.com