Posts

Showing posts with the label Asp.NET Core

Components of Tasks & Threading in .NET

Image
I recommend understanding the basics of async and await before you read this article. This is a good introduction from Stephen Cleary. As you might know simply using async and await doesn't mean your code is executed on different threads. To achieve this you must use Task.Run , TaskFactory.StartNew or the Task Parallel Library . This is an introduction in the different components at play when you want to schedule tasks on different threads. TaskFactory The TaskFactory is a simple container where you can configure options for the creation and continuation of Tasks. Furthermore you can specify an canncelation Token which will be used by all Tasks created through this factory. And lastly you can define your own TaskScheduler. It's your choise if you want to use a TaskFactory to start a new task or if you want to start a task directly trough Task.Run. MSDN TaskFactory TaskScheduler The TaskScheduler is responsible to run the next task on the correct ...