private static void TaskExecuted(ref int numberOfTasks, ManualResetEvent signal) { if (Interlocked.Decrement(ref numberOfTasks) == 0) { //освобождение потоков _taskQueue.DisposePool(); signal.Set(); } }