AwaitableCoroutine is a library for C# that provides a coroutine that allows the use of async/await syntax. Internally it uses Task-Like, the Awaitable pattern, and AsyncMethodBuilder.
AwaitableCoroutine は、async/await 構文を使用可能にしたコルーチンを提供する C# 向けライブラリです。 内部的にはTask-Like、Awaitable パターン、AsyncMethodBuilder が使われています。
Install from NuGet Gallery
PackageId | Badge |
---|---|
AwaitableCoroutine | |
AwaitableCoroutine.Altseed2 | |
AwaitableCoroutine.FSharp |
lang | link |
---|---|
ja | ドキュメント |
en | Document |
using System;
using AwaitableCoroutine;
var runner = new CoroutineRunner();
int count = 0;
var coroutine = runner.Create(async () => {
Console.WriteLine("Started!");
for (var i = 0; i < 10; i++)
{
count++;
await Coroutine.Yield();
}
}).OnCompleted(() => Console.WriteLine("Finished!"));
while (true)
{
runner.Update();
if (coroutine.IsCompletedSuccessfully) break;
Console.WriteLine($"{count}");
}
$ dotnet run --project examples/AwaitableCoroutine.Example
Started!
0
1
2
3
4
5
6
7
8
9
10
Finished!
see examples in detail.
$ dotnet tool restore
$ dotnet fake build [-- <DEBUG|RELEASE>]
Default configuration is DEBUG
$ dotnet fake build -t format
$ dotnet fake build -t test
$ dotnet pack -c Release