2using System.Threading.Tasks;
11 private static readonly LinkedList<IAsyncProcessor> activeProcessors =
new LinkedList<IAsyncProcessor>();
18 internal static LinkedListNode<IAsyncProcessor> RegisterProcessor(
IAsyncProcessor Processor)
20 lock (activeProcessors)
22 return activeProcessors.AddLast(Processor);
30 internal static void UnregisterProcessor(LinkedListNode<IAsyncProcessor> Node)
34 lock (activeProcessors)
36 if (!(Node.List is
null))
37 activeProcessors.Remove(Node);
48 lock (activeProcessors)
51 activeProcessors.CopyTo(Result, 0);
63 lock (activeProcessors)
65 return !(activeProcessors.First is
null);
100 int i, c = Processors.Length;
101 Task[] Tasks =
new Task[c];
103 for (i = 0; i < c; i++)
104 Tasks[i] = Processors[i].CloseForTermination(WaitForCompletion, Timeout);
106 if (WaitForCompletion)
107 await Task.WhenAll(Tasks);
Maintains a record of active processors.
static Task CloseAllProcessorsForTermination(bool WaitForCompletion)
Closes all active processors for new items. If WaitForCompletion is true, the method waits for queue...
static IAsyncProcessor[] GetActiveProcessors()
Gets an array of all active processors.
static async Task CloseAllProcessorsForTermination(bool WaitForCompletion, int Timeout)
Closes all active processors for new items. If WaitForCompletion is true, the method waits for queue...
static Task CloseAllProcessorsForTermination()
Closes all active processors for new items.
static bool HasActiveProcessors
If there are active processors.
Interface for AsyncProcessor<T> instances.