Low allocation coroutines with tightly controlled concurrency.
Add the following to your Directory.Build.props
or csproj
:
<ItemGroup>
<PackageReference Include="CoroutineScheduler" Version="x.y.z" />
</ItemGroup>
using CoroutineScheduler;
var scheduler = new Scheduler();
// spawn a coroutine
scheduler.SpawnTask(MyCoroutine);
while (true)
scheduler.Resume();
async Task MyCoroutine()
{
int i = 0;
while (true)
{
Console.WriteLine($"Hello {i++}");
await scheduler.Yield();
}
}