C# - How to return a completed Task with or without a result
When using tasks you at some point come across having to return a Task without actually having a Task to return. The usual case is in »
When using tasks you at some point come across having to return a Task without actually having a Task to return. The usual case is in »
You are likely here because you are trying to make your main method use the async keyword. The gotcha I ran into - which is quite »
What you are likely looking for is the method Task.WaitAll(task1, task2, task3..);. The method allows you to wait for several tasks to finish, even »
With .Net 6 we got the new Parallel.ForEachAsync method from the parallel library. Previously we had to make do with Parallel.ForEach method which had »
So you are likely here because you cannot remember the syntax for returning a task with a named tuple, in short you are likely just looking »
I recently stumbled upon some code which looked something like the following: var ct = new CancellationToken(); Task.Run(async () => { while (!ct.IsCancellationRequested) { CallToMethodThatMightThrowAnException(); await Task. »
I have not yet found a situation where I needed a thread instead of a Task. Threads are a lower level concept when compared to tasks. »
It is quite easy to start a new thread in C#. All you need is to instantiate a new object of the type Thread and call »
In this post I will show how the lock statement in C# works and what you should look out for when using it. It is well »
I had a discussion a couple of weeks ago about tasks and threads. It occurred to me that I had rarely used threads and mostly used »