Utilizing multiple threads
Traditionally, all applications were developed as single threaded applications. However, when long running background processes were running, the application UI would freeze and become unresponsive, because the single thread was busy elsewhere. This problem and other performance bottlenecks led to the current era of asynchronous programming and multi-threaded applications.
In days gone by, creating multi-threaded applications was a complicated matter. With each successive version of the .NET Framework, Microsoft have striven to make this task easier. Originally, we only had the Thread class and then the BackgroundWorker
class in .NET 2.0, but in .NET 4.0, they introduced the Task
class and in .NET 4.5, they introduced the async
and await
keywords.
In this section, we will explore the latter methods of multithreading and add functionality to our application framework that will enable us to perform our data retrieval and update actions asynchronously. Let's start...