A .NET utility library for running async methods in parallel batches.
Available on NuGet:
and GitHub:
On the side, working on improving usage of
Example usage:
usingCSRakowski.Parallel;List<string>fileUrls=GetFileUrls();varfiles=awaitParallelAsync.ForEachAsync(fileUrls,(url)=>{returnDownloadFileAsync(url);},maxBatchSize:8,allowOutOfOrderProcessing:true);As of version 1.1 a fluent syntax is also available:
usingCSRakowski.Parallel.Extensions;List<string>fileUrls=GetFileUrls();varfiles=awaitfileUrls.AsParallelAsync().WithMaxDegreeOfParallelism(8).WithOutOfOrderProcessing(false).ForEachAsync((url)=>{returnDownloadFileAsync(url);});In version 1.6, support for Async Streams has been added.
This allows you to chain together multiple invocations by passing along an IAsyncEnumerable<T>, sort of like a pipeline:
usingCSRakowski.Parallel;List<string>fileUrls=GetFileUrls();varfileDataStream=ParallelAsync.ForEachAsyncStream(fileUrls,(url)=>{returnDownloadFileAsync(url);},maxBatchSize:4,allowOutOfOrderProcessing:true);varresultStream=ParallelAsync.ForEachAsyncStream(fileDataStream,(fileData)=>{returnParseFileAsync(fileData);},maxBatchSize:4,allowOutOfOrderProcessing:true);awaitforeach(varresultinresultStream){HandleResult(result);}- Dropped support for .NET 6.0
- Updated TargetFrameworks to remove old unsupported ones.
- First attempt at enabling SourceLink.
- Updated to latest
CSRakowski.AsyncStreamsPreparations, which usesMicrosoft.Bcl.AsyncInterfaces(correctly...).
- Updated to latest
CSRakowski.AsyncStreamsPreparations, which usesMicrosoft.Bcl.AsyncInterfaces.
- Added support for Async Streams, so you produce an
IAsyncEnumerable<T>.
- Added .NET 6.0 TargetFramework
- Fixed dependency misconfiguration on net50
- Updated target frameworks
- Updated target frameworks
- Updated dependencies
- Added gist support for
IAsyncEnumberable<T>
- Added the RunId to the BatchStart and BatchStop events
- Reduced overhead in code paths where the input collection is a
T[],maxBatchSizeis greater than1andallowOutOfOrderisfalse
- Changed assembly signing key
- Further changes to internal implementation details
- Performance improvements when the input collection is a
T[]orIList<T>andmaxBatchSizeis set to1 - Performance improvements in the
allowOutOfOrdercode paths.
- Marked the
Ton theIParallelAsyncEnumerableas covariant - Changes to internal implementation details
- Added an
EventSourceto expose some diagnostic information. - Changed minimum supported NetStandard from 1.0 to 1.1 (Because of the
EventSource).
- Added support for
IReadOnlyCollection<T>to theListHelper. - Added more XmlDoc to methods and classes.
- Renamed class to
ParallelAsyncto prevent naming conflicts with theSystem.Threading.Tasks.Parallel. - Renamed namespace to
CSRakowski.Parallelto prevent ambiguous name conflicts between the class and the namespace. - Added new extension methods to allow for fluent sytax usage.
- Enabled Strong Naming.
- Initial release.