So we have this class implementing IValueTaskSource This code cannot be written as async-await because there's nothing to await on. We send a message ...
So we have this class implementing IValueTaskSource This code cannot be written as async-await because there's nothing to await on. We send a message ...
In our project we used EF Core 2.2.6. But after upgrading to EF Core 3.1, the following piece of code stopped compiling and giving an error Erro ...
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 t ...
I'm trying out Parallel.ForEachAsync and the compiler is kind enough to inform me that the body is a func that returns a ValueTask, not a Task. A q ...
There is a library returning a ValueTask and I have a synchronous method which is consuming the ValueTask. The issue is that there is the following wa ...
I'm doing a benchmark on Task<T> and ValueTask<T>. Source code below: #LINQPad optimize+ // Enable compiler optimizations void Main( ...
Let's say I have a method that returns an object of type ValueTask, for example the WaitToReadAsync method on ChannelReader. There are three ways I ca ...
ValueTask and ValueTask<TResult> have a Preserve() method which is summarized as "Gets a ValueTask that may be used at any point in the future." ...
I am writting an API that has a ValueTask<T> return type, and accepts a CancellationToken. In case the CancellationToken is already canceled upo ...
I currently have the following async method: If the above code is a hot path and called many times, is it safe/ok to change to use ValueTask? Wh ...
Using the following methods as an example: public async ValueTask<int> MyMethod() { return await GetMyIntegerWithTask(); } public async Ta ...
I have a simple ITimer interface that has just a classic Elapsed .NET event that is raised after the a certain timespan. interface ITimer { void ...
I am implementing a simple lookup service using concurrent dictionary to store data. Since most of the methods using this service will be async I am c ...
case 1: case 2: With case 1 and case 2 above, can anyone say case 2 is better for performance(cpu, memory, etc.)? Or, is task.IsComple ...
If an API returns a ValueTask or ValueTask<T>, is there a way to perform a ContinueWith on it, like I'm able to do with Task? Is there a Microso ...
The question asked here is the same as the one here and is aimed to create a definitive solution to it. The most accurate answer is by Stephen Toub hi ...
I am implementing IAsyncDisposable which requires me to return a ValueTask, but sometimes my dispose method has nothing to do. How should I return in ...
I have an async method that looks approximately like this: This method is going to work synchronously most of the time as data is already ready. So ...
I am passing an async delegate to the LINQ Select method, and I would prefer to get a list of ValueTasks instead of a list of Tasks. How can I do it? ...
According to the documentation a ValueTask<TResult>... Provides a value type that wraps a Task<TResult> and a TResult, only one of whi ...