.NET - Start Asynchronous Parallel Task and Cancel Them Too

I was having a good discussion with a couple of friends about the support of parallel tasks in .NET. If you too are interested in the same, I have written a couple of articles that can give you an overview of the support for parallelism and concurrency in .NET applications.

Parallel Tasks in .NET 4.0 -   The Parallel class found in the System.Threading.Tasks namespace “provides library-based data parallel replacements for common operations such as for loops, for each loops, and execution of a set of statements”. In this article, we will use the Invoke method of the Parallel class to call multiple methods, possibly in parallel.

Parallel Tasks in .NET 4.0 (Part II) – Methods that Return value - In one of the previous articles Parallel Tasks in .NET 4.0, we explored a set of new API’s called the "Task Parallel Library (TPL)" which simplifies the process of adding parallelism and concurrency to applications. We used the System.Threading.Tasks.Parallel.Invoke() to call methods that did not return a value. However for methods that return a value, you would need to use the Task(TResult) class which represents an asynchronous operation that can return a value. We will explore how to use this class in this article

Cancelling Tasks in .NET 4.0 - In one of the previous articles Parallel Tasks in .NET 4.0 (Part II) – Methods that Return value, we used the Task(TResult) class which represents an asynchronous operation that can return a value. In this article, we will see how to cancel a task/operation.

Parallel.For Method in .NET 4.0 vs the C# For Loop - In this article, we will explore the static method Parallel.For. A lot of developers ask me about the difference between the C# for loop statement and the Parallel.For. We will see the difference with an example

On a side note, there are many ways to call a method asynchronously using .NET Delegates. Here are two articles that give you an overview of the same

Call a Method Asynchronously using Delegate BeginInvoke and EndInvoke Pattern - In this article, we will explore multiple ways to call a method asynchronously using Delegates. You can call methods asynchronously in four different ways using the BeginInvoke() and EndInvoke() methods of the Delegate class

Call a Method Asynchronously in .NET using Polling Pattern and Callback Pattern - In my previous article, we explored multiple ways to call a method asynchronously using Delegates. In this article, we will see how to call a method asynchronously using the Delegate Polling pattern and the Callback Pattern.


Will you give this article a +1 ? Thanks in advance


About The Author

Suprotim Agarwal
Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook

Follow him on twitter @suprotimagarwal

No comments: