All Projects → StephenCleary → Asyncex

StephenCleary / Asyncex

Licence: mit
A helper library for async/await.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to Asyncex

Await Of
await wrapper for easier errors handling without try-catch
Stars: ✭ 240 (-91.41%)
Mutual labels:  async, async-await, await
P Iteration
Utilities that make array iteration easy when using async/await or Promises
Stars: ✭ 337 (-87.94%)
Mutual labels:  async, async-await, await
Coerce Rs
Coerce - an asynchronous (async/await) Actor runtime and cluster framework for Rust
Stars: ✭ 231 (-91.73%)
Mutual labels:  async, async-await, await
P Map
Map over promises concurrently
Stars: ✭ 639 (-77.13%)
Mutual labels:  async, async-await, await
Then
🎬 Tame async code with battle-tested promises
Stars: ✭ 908 (-67.5%)
Mutual labels:  async, task, async-await
Taskbuilder.fs
F# computation expression builder for System.Threading.Tasks
Stars: ✭ 217 (-92.23%)
Mutual labels:  async, task, await
Unityfx.async
Asynchronous operations (promises) for Unity3d.
Stars: ✭ 143 (-94.88%)
Mutual labels:  async, task, async-await
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (-75.3%)
Mutual labels:  async, async-await, await
Asyncawaitbestpractices
Extensions for System.Threading.Tasks.Task and System.Threading.Tasks.ValueTask
Stars: ✭ 693 (-75.2%)
Mutual labels:  async, task, await
Swimmer
🏊 Swimmer - An async task pooling and throttling utility for JS
Stars: ✭ 94 (-96.64%)
Mutual labels:  async, task, await
Use Async Effect
🏃 Asynchronous side effects, without the nonsense
Stars: ✭ 193 (-93.09%)
Mutual labels:  async, async-await, await
Async Backplane
Simple, Erlang-inspired fault-tolerance framework for Rust Futures.
Stars: ✭ 113 (-95.96%)
Mutual labels:  async, async-await
Rubico
[a]synchronous functional programming
Stars: ✭ 133 (-95.24%)
Mutual labels:  async, async-await
Nim Chronos
Chronos - An efficient library for asynchronous programming
Stars: ✭ 136 (-95.13%)
Mutual labels:  async, async-await
Futures Intrusive
Synchronization primitives for Futures and async/await based on intrusive collections
Stars: ✭ 137 (-95.1%)
Mutual labels:  async, async-await
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (-95.99%)
Mutual labels:  async, async-await
Cppcoro
A library of C++ coroutine abstractions for the coroutines TS
Stars: ✭ 2,118 (-24.19%)
Mutual labels:  async, async-await
Mobc
A generic connection pool for Rust with async/await support
Stars: ✭ 141 (-94.95%)
Mutual labels:  async, await
Async
Easily run code asynchronously
Stars: ✭ 1,983 (-29.03%)
Mutual labels:  async, await
Micro
Asynchronous HTTP microservices
Stars: ✭ 9,987 (+257.44%)
Mutual labels:  async, await

Logo

AsyncEx

A helper library for async/await.

Note: This README is for AsyncEx v5 (the current version). For AsyncEx v4, see here.

Supports netstandard1.3 (including .NET 4.6, .NET Core 1.0, Xamarin.iOS 10, Xamarin.Android 7, Mono 4.6, and Universal Windows 10).

NuGet Pre Release netstandard 1.3 netstandard 2.0 Code Coverage Build status

API docs

Overview - Upgrade Guide

Getting Started

Install the NuGet package.

AsyncLock

A lot of developers start using this library for AsyncLock, an async-compatible mutual exclusion mechanism. Using AsyncLock is straightforward:

private readonly AsyncLock _mutex = new AsyncLock();
public async Task UseLockAsync()
{
  // AsyncLock can be locked asynchronously
  using (await _mutex.LockAsync())
  {
    // It's safe to await while the lock is held
    await Task.Delay(TimeSpan.FromSeconds(1));
  }
}

AsyncLock also fully supports cancellation:

public async Task UseLockAsync()
{
  // Attempt to take the lock only for 2 seconds.
  var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2));
  
  // If the lock isn't available after 2 seconds, this will
  //  raise OperationCanceledException.
  using (await _mutex.LockAsync(cts.Token))
  {
    await Task.Delay(TimeSpan.FromSeconds(1));
  }
}

AsyncLock also has a synchronous API. This permits some threads to acquire the lock asynchronously while other threads acquire the lock synchronously (blocking the thread).

public async Task UseLockAsync()
{
  using (await _mutex.LockAsync())
  {
    await Task.Delay(TimeSpan.FromSeconds(1));
  }
}

public void UseLock()
{
  using (_mutex.Lock())
  {
    Thread.Sleep(TimeSpan.FromSeconds(1));
  }
}

Other Coordination Primitives

AsyncLock is just the beginning. The AsyncEx library contains a full suite of coordination primitives: AsyncManualResetEvent, AsyncAutoResetEvent, AsyncConditionVariable, AsyncMonitor, AsyncSemaphore, AsyncCountdownEvent, and AsyncReaderWriterLock.

More Stuff

There's quite a few other helpful types; see the docs for full details

Infrequently Asked Questions

Older Platforms

AsyncEx v4 supported .NET 4.0, Windows Store 8.1, Windows Phone Silverlight 8.0, Windows Phone Applications 8.1, and Silverlight 5.0. Support for these platforms has been dropped with AsyncEx v5.

AsyncEx v3 supported Windows Store 8.0, Windows Phone Silverlight 7.5, and Silverlight 4.0. Support for these platforms has been dropped with AsyncEx v4.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].