Category Archives: Asynchronous Programming

Asynchronous Programming

Asynchronous Programming – Task.CompletedTask and Task.FromResult

By | 18/01/2023

In this post, we will see how and when using Task.CompletedTask and Task.FromResult. WHENWe can use both of them when, we need to return a Task object from a method that don’t have any async operations. HOWTask.CompletedTaskWhen we need to return a Task: [CORE.CS] [PROGRAM.CS] If we run the application, this will be the result:… Read More »

Asynchronous Programming – WhenAll vs WaitAll

By | 27/07/2022

In this post, we will see the differences between WhenAll and WaitAll in the Asynchronous Programming. We start creating a Console Application called TestAysncAwait where, we will add two classes called ClassWaitAllTest and ClassWhenAllTest: [CLASSWAITALLTEST.COM] [CLASSWHENALLTEST.COM] Then, we modify the Program.cs file in order to run and testing ClassWaitAllTest: [PROGRAMM.CS] We have done and now,… Read More »

Asynchronous Programming – Task and Cancellation Token

By | 20/07/2022

In this post, we will see how to use a Cancellation Token in a Task.But first of all, what is a Cancellation Token?From Microsoft web site:“A CancellationToken enables cooperative cancellation between threads, thread pool work items, or Task objects“.In a nutshell, when we run a Task and we decide to cancel it, using a cancellation token we will stop… Read More »

Asynchronous Programming – Introduction in C#

By | 26/05/2021

In this post, we will see how to manage Asynchronous Programming in C#.Asynchronous programming is a means of parallel programming in which a unit of work runs separately from the main application thread and notifies the calling thread of its completion, failure or progress.Obviously, there would be many things to see and understand in Asynchronous… Read More »