AsyncEnumerator 1.0.3
Introduces IAsyncEnumerable, IAsyncEnumerator, and ForEachAsync()
GitHub: https://github.com/tyrotoxin/AsyncEnumerable
PROBLEM SPACE
Helps to (a) create an element provider, where producing an element can take a lot of time
due to dependency on other asynchronous events (e.g. wait handles, network streams), and
(b) a consumer that processes those element as soon as they are ready without blocking
the thread (the processing is scheduled on a worker thread instead).
EXAMPLE
using System.Collections.Async;
static IAsyncEnumerable<int> ProduceAsyncNumbers(int start, int end)
{
return new AsyncEnumerable<int>(async yield => {
// Just to show that ReturnAsync can be used multiple times
await yield.ReturnAsync(start);
for (int number = start + 1; number <= end; number++)
await yield.ReturnAsync(number);
// You can break the enumeration loop with the following call:
yield.Break();
// This won't be executed due to the loop break above
await yield.ReturnAsync(12345);
});
}
// Just to compare with synchronous version of enumerator
static IEnumerable<int> ProduceNumbers(int start, int end)
{
yield return start;
for (int number = start + 1; number <= end; number++)
yield return number;
yield break;
yield return 12345;
}
static async Task ConsumeNumbersAsync()
{
var asyncEnumerableCollection = ProduceAsyncNumbers(start: 1, end: 10);
await asyncEnumerableCollection.ForEachAsync(async number => {
await Console.Out.WriteLineAsync($"{number}");
});
}
// Just to compare with synchronous version of enumeration
static void ConsumeNumbers()
{
// NOTE: IAsyncEnumerable is derived from IEnumerable, so you can use either
var enumerableCollection = ProduceAsyncNumbers(start: 1, end: 10);
//var enumerableCollection = ProduceNumbers(start: 1, end: 10);
foreach (var number in enumerableCollection) {
Console.Out.WriteLine($"{number}");
}
}
See the version list below for details.
Install-Package AsyncEnumerator -Version 1.0.3
dotnet add package AsyncEnumerator --version 1.0.3
<PackageReference Include="AsyncEnumerator" Version="1.0.3" />
paket add AsyncEnumerator --version 1.0.3
#r "nuget: AsyncEnumerator, 1.0.3"
// Install AsyncEnumerator as a Cake Addin
#addin nuget:?package=AsyncEnumerator&version=1.0.3
// Install AsyncEnumerator as a Cake Tool
#tool nuget:?package=AsyncEnumerator&version=1.0.3
Release Notes
Add ForEachAsync overloaded method with item index as the second argument of a callback action
Dependencies
This package has no dependencies.
Used By
NuGet packages (28)
Showing the top 5 NuGet packages that depend on AsyncEnumerator:
Package | Downloads |
---|---|
NBitcoin.Indexer
Library for querying data indexed by NBitcoin.Indexer on Azure Storage
|
|
Elect.Core
.Net Core Utilities methods
|
|
Mighty
A new small, happy, dynamic micro-ORM and general purpose .NET data access wrapper.
Based on and highly compatible with Massive, but now with:
* .NET Core 1.0+, 2.0+ and 3.0+ (with continuing support for .NET Framework 4.0+ and 4.5+)
* Optional strong typing (with continuing full support for dynamic types)
* Full stored procedure support
* Parameter names and directions (where you need it; automatic parameter naming as in Massive still works just as before)
* Full transaction support
* Cursor support on Oracle and PostgreSQL (cursors are not designed to be passed out to client code on any other supported databases)
* Multiple result sets
* Simultaneous access to more then one database provider
|
|
Halforbit.RecordStreams
Package Description
|
|
Halforbit.RecordStreams.BlobStorage
Package Description
|
GitHub repositories (5)
Showing the top 5 popular GitHub repositories that depend on AsyncEnumerator:
Repository | Stars |
---|---|
RevoLand/Steam-Library-Manager
Open source utility to manage Steam, Origin and Uplay libraries in ease of use with multi library support
|
|
planetarium/libplanet
Blockchain core in C#/.NET for persistent peer-to-peer online games
|
|
Dasync/Dasync
Every developer deserves the right of creating microservices without using any framework 🤍
|
|
Texnomic/SecureDNS
Secure, Modern, Fully-Featured, All-In-One Cross-Architecture & Cross-Platform DNS Server Using C# 8.0 & .NET Core 3.1
|
|
smartstore/Smartstore
Open Source ASP.NET Core Enterprise eCommerce Shopping Cart Solution
|
Version History
Version | Downloads | Last updated |
---|---|---|
4.0.2 | 1,269,778 | 12/4/2019 |
4.0.1 | 76,640 | 10/22/2019 |
4.0.0 | 8,265 | 10/18/2019 |
3.1.0 | 54,513 | 9/23/2019 |
2.2.2 | 1,091,725 | 1/27/2019 |
2.2.1 | 1,178,614 | 5/29/2018 |
2.2.0 | 25,572 | 5/18/2018 |
2.1.1 | 111,980 | 1/20/2018 |
2.1.0 | 228,000 | 5/22/2017 |
2.0.1 | 49,281 | 2/13/2017 |
1.5.0 | 3,650 | 2/12/2017 |
1.4.2 | 1,411 | 2/6/2017 |
1.3.0 | 1,675 | 1/20/2017 |
1.2.3 | 6,658 | 1/6/2017 |
1.2.2 | 1,908 | 12/11/2016 |
1.2.1 | 664 | 12/10/2016 |
1.2.0 | 18,520 | 11/29/2016 |
1.1.3 | 712 | 11/28/2016 |
1.1.2 | 42,198 | 8/29/2016 |
1.0.3 | 3,441 | 4/28/2016 |