A .NET library for async/await, by Stephen Cleary. It contains a rich toolset of coordination primitives like the AsyncLock, AsyncManualResetEvent, AsyncAutoResetEvent, AsyncConditionVariable, AsyncMonitor, AsyncSemaphore, AsyncCountdownEvent, and AsyncReaderWriterLock.
Questions tagged [nito.asyncex]
10 questions
4
votes
2 answers
Is it OK to cache IAsyncEnumerable for multiple consumers?
I am examining the effects of replacing some instances of regular C# event pattern with IAsyncEnumerable. This would be accomplished by lazy instantiation/activation of an IAsyncEnumerable and caching that reference for use by all callers/listeners.…

KyleP
- 334
- 2
- 12
3
votes
1 answer
ThreadPool's Thread creation event
Is there a way to be notified (e.g. via an event or a callback) whenever a new ThreadPool thread is created?
I'm working on a .net console app that is using pjlib library via P/Invoke. This library requires that every thread that uses any of its…

Oaraisi
- 45
- 1
- 8
3
votes
1 answer
Correct usage for Nito.AsyncEx.AsyncContext.Run
I am using the excellent library from Steven called AsyncEx to help me baby-step the transition of an old codebases across to the async world.
The docs say..
class Program
{
static async Task AsyncMain()
{
..
}
static int…

Sam
- 535
- 5
- 14
2
votes
2 answers
How to Pause/Resume an asynchronous worker, without incurring memory allocation overhead?
I have an asynchronous method that contains an endless while loop. This loop is paused and resumed frequently by the main thread of the program. For this purpose I am using currently the PauseTokenSource class from the Nito.AsyncEx package:
private…

Theodor Zoulias
- 34,835
- 7
- 69
- 104
2
votes
1 answer
Observable wrapper for AsyncProducerConsumerQueue
So I created an observable wrapper for Stephen Cleary's AsyncProducerConsumerQueue with the following code.
I'm wondering if anyone here knows how I could have done this in a much simpler way?
Could it have been written without a wrapper…

bboyle1234
- 4,859
- 2
- 24
- 29
1
vote
1 answer
What are the differences between AsyncEx.AsyncLock and Scott Hanselman's AsyncLock?
I recently had the need to add an asynchronous variant of the lock keyword to one of my applications. There are many implementations to choose from, but the two that most appealed to me were:
AsyncLock from the AsyncEx library.
Main reason: It's…

cremor
- 6,669
- 1
- 29
- 72
1
vote
2 answers
Should we use ValueTask within System.Threading.Channels.WaitToReadAsync loops?
Since we expect to be reading frequently, and for us to often be reading when data is already available to be consumed, should SendLoopAsync return ValueTask rather than Task, so that we can make it allocation-free?
// Caller
_ =…

nop
- 4,711
- 6
- 32
- 93
1
vote
1 answer
Is Nito.AsyncEx's AsyncProducerConsumerQueue performant enough to handle gigabytes of bytes?
Is AsyncProducerConsumerQueue (maxCount: 10*1024*204) designed to handle gigabytes of bytes or is there a better way to create a streaming queue for a gigabyte of bytes? Is it better to put byte[] of some size into the queue?
It just sounds…

D.R.
- 20,268
- 21
- 102
- 205
0
votes
2 answers
How to check if another thread is within a locked section, using AsyncEx?
I've just started using Nito.AsyncEx package and AsyncLock instead of a normal lock() { ... } section where I have async calls within the locked section (since you can't use lock() in such cases for good reasons I've just read about). This is within…

Rory
- 40,559
- 52
- 175
- 261
0
votes
1 answer
Running into deadlocks code using AsyncContext
This is my code, I'm using AsyncEx in my library to try to get around potential deadlocks, but I ended up in there anyway:
return AsyncContext.Run(async () =>
{
var get = await httpClient.GetAsync(url);
if (get.IsSuccessStatusCode &&…

f00f
- 123
- 1
- 11