Workaround for the WaitHandle.WaitAll 64 handle limit?

Create a variable that keeps track of the number of running tasks:

int numberOfTasks = 100;

Create a signal:

ManualResetEvent signal = new ManualResetEvent(false);

Decrement the number of tasks whenever a task is finished:

if (Interlocked.Decrement(ref numberOftasks) == 0)

If there is no task remaining, set the signal:


Meanwhile, somewhere else, wait for the signal to be set:


Leave a Comment