| Build | NuGet |
|---|---|
A collection of tools that support asynchronous methods and support high-performance multithreading.
Two different libraries are provided for installation.
.NET CLI:
dotnet add package dotnetCampus.AsyncWorkerCollection
PackageReference:
<PackageReferenceInclude="dotnetCampus.AsyncWorkerCollection"Version="1.2.1" />Install the SourceYard NuGet source code
.NET CLI:
dotnet add package dotnetCampus.AsyncWorkerCollection.Source --version 1.2.1
PackageReference:
<PackageReferenceInclude="dotnetCampus.AsyncWorkerCollection.Source"Version="1.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>An asynchronous queue that supports multiple threads
Create a queue:
varasyncQueue=newAsyncQueue<FooTask>();Add task to queue:
asyncQueue.Enqueue(newFooTask());Waiting for the task to dequeue:
varfooTask=awaitasyncQueue.DequeueAsync();The advantage of AsyncQueue over Channel is that it supports .NET Framework 45 and simple
DoubleBufferTask supports multi-threaded fast input data and single-threaded batch processing of data, and supports waiting for buffer execution to complete
vardoubleBufferTask=newDoubleBufferTask<Foo>(list =>{// Method to perform batch List<Foo> tasks// The incoming delegate will be called when there is data in the DoubleBufferTask, and it means that there is at least one element in the list});// Multiple other threads call this code to add the task datadoubleBufferTask.AddTask(newFoo());// After the business code is completed, call the Finish method to indicate that no more tasks are added// This Finish method is not thread-safedoubleBufferTask.Finish();// Other threads can call WaitAllTaskFinish to wait for the completion of all task data in DoubleBufferTask// It will return after be Finish method be called and the all the task data be handledawaitdoubleBufferTask.WaitAllTaskFinish();Asynchronous version of AutoResetEvent lock
AsyncAutoResetEvent is functionally the same as AutoResetEvent, except that WaitOne is replaced with WaitOneAsync to support asynchronous waiting
Asynchronous version of ManualResetEvent lock
AsyncManualResetEvent is functionally the same as ManualResetEvent, except that WaitOne is replaced with WaitOneAsync to support asynchronous waiting
See Benchmark.md
If you would like to contribute, feel free to create a Pull Request, or give us Bug Report.