i have an async Task like this:
public async Task DoWork()
{
}
And i have at the moment a:
List tmp = new List<
Actually, the tasks start as soon as you call DoWork
; when you await
them, you are finishing the tasks.
One option for throttling tasks is SemaphoreSlim, which you can use as such:
private SemaphoreSlim _mutex = new SemaphoreSlim(3);
public async Task DoWorkAsync()
{
await _mutex.WaitAsync();
try
{
...
}
finally
{
_mutex.Release();
}
}
Another option is to use an actual queue, like an ActionBlock