|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Callback Delimma...1. Multiple threads will make REQUESTs. (I synchronous request per thread) The number of threads could vary.. (1..n) where n could be 10,000. 2. A separate thread will be monitoring the central RESPONSE depository. (queue/list whatever...) 3. Each request/response will have a matching unique ID so that the monitoring thread can route the response back to the proper thread that made the request. So the monitoring thread will simply receive the response, determine it's destination (request thread), and send it back... 4. I don't want 10,000 threads to poll or search for their specific response ! That would be very inefficient... 5. My setup is : (xp, vs2005, framework 2.0, c#) How is the "best" way to implement STEP 3 in a C# ???? You've pretty much described IAsyncResult , and the problem that it was
designed to solve. I would suggest reading some articles people have put together on writing asynchronous code, and making use of IAsyncResult. This pattern makes use of a ManualResetEvent, so each of your 10k threads ends up blocking on a particular event, and the wait is therefore pretty efficient. When the "worker" thead completes a task, it sets the event inside the AsyncResult, which causes the originally blocked thread to wake up and being processing. I would normally send you some links, but there are so many articles on the web, that you can just hit Google and get more than you'll know what to do with... -- Show quoteChris Mullins, MCSD.NET, MCPD:Enterprise, Microsoft C# MVP http://www.coversant.com/blogs/cmullins <altagr***@gmail.com> wrote in message news:1176392122.670300.308540@y5g2000hsa.googlegroups.com... > Greetings, > > 1. Multiple threads will make REQUESTs. (I synchronous request per > thread) The number of threads could vary.. (1..n) where n could be > 10,000. > > 2. A separate thread will be monitoring the central RESPONSE > depository. (queue/list whatever...) > > 3. Each request/response will have a matching unique ID so that the > monitoring thread can route the response back to the proper thread > that made the request. So the monitoring thread will simply receive > the response, determine it's destination (request thread), and send it > back... > > 4. I don't want 10,000 threads to poll or search for their specific > response ! That would be very inefficient... > > 5. My setup is : (xp, vs2005, framework 2.0, c#) > > How is the "best" way to implement STEP 3 in a C# ???? > |
|||||||||||||||||||||||