Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jerry08/taskexecutor

Task Helper
https://github.com/jerry08/taskexecutor

Last synced: 4 days ago
JSON representation

Task Helper

Awesome Lists containing this project

README

        


TaskExecutor



**TaskExecutor** is a library that makes it easier to run multiple tasks simultaneously by using of Semaphore.

## Install

- 📦 [NuGet](https://nuget.org/packages/TaskExecutor): `dotnet add package TaskExecutor`

## Usage

```csharp
using System;
using System.Linq;
using System.Threading.Tasks;
using TaskExecutor;

var myAction = MyActionAsync;
var actions = Enumerable.Range(0, 11).Select(_ => myAction);

// This runs 2 tasks at a time and wait unitl all tasks are completed.
var result = await TaskEx.Run(actions, 2);

static int HelloCount;
async Task MyActionAsync()
{
await Task.Delay(1000);

HelloCount++;
Console.WriteLine($"Hello ({HelloCount})");

return 0;
}
```