Skip to content

Latest commit

 

History

History
110 lines (78 loc) · 2.27 KB

README.md

File metadata and controls

110 lines (78 loc) · 2.27 KB

AwaitableCoroutine

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 が使われています。

Installation

Install from NuGet Gallery

PackageId Badge
AwaitableCoroutine AwaitableCoroutine - NuGet Gallery
AwaitableCoroutine.Altseed2 AwaitableCoroutine.Altseed2 - NuGet Gallery
AwaitableCoroutine.FSharp AwaitableCoroutine.FSharp - NuGet Gallery

Documentation

lang link
ja ドキュメント
en Document

Example

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.

Command (for dev)

Setup

$ dotnet tool restore

Build

$ dotnet fake build [-- <DEBUG|RELEASE>]

Default configuration is DEBUG

Format

$ dotnet fake build -t format

Test

$ dotnet fake build -t test

Pack

$ dotnet pack  -c Release