Can you have too many Delegate.BeginInvoke calls at once?

Posted by stewsha on Stack Overflow See other posts from Stack Overflow or by stewsha
Published on 2010-06-12T18:00:58Z Indexed on 2010/06/12 18:13 UTC
Read the original article Hit count: 247

Filed under:
|

I am cleaning up some old code converting it to work asynchronously.

psDelegate.GetStops decStops = psLoadRetrieve.GetLoadStopsByLoadID;
var arStops = decStops.BeginInvoke(loadID, null, null);
WaitHandle.WaitAll(new WaitHandle[] { arStops.AsyncWaitHandle });
var stops = decStops.EndInvoke(arStops);

Above is a single example of what I am doing for asynchronous work. My plan is to have close to 20 different delegates running. All will call BeginInvoke and wait until they are all complete before calling EndInvoke.

My question is will having so many delegates running cause problems? I understand that BeginInvoke uses the ThreadPool to do work and that has a limit of 25 threads. 20 is under that limit but it is very likely that other parts of the system could be using any number of threads from the ThreadPool as well.

Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET