Shadman Kudchikar

C# Threading Tutorial

Introduction

Applications are getting complex as user expectation rise. To truly utilize multicore processor system and stay responsive at the same time, one must use multiple threads in an application, often called as parallelism.

In this tutorial you will learn how to take advantage of Thread Class provided by C# and .NET Framework to create robust applications that are responsive, parallel and meet the user expectations.

Futher, we will discuss the issue in terms of program correctness in a multithreaded program. And then we’ll take a look at some of the thread synchronization techniques that are available to you as a CLR or .NET programmer.

Finally, we’re going to look at task-based approach provided by C# .NET for async and parallel programming.

Modules

What You Will Learn

  • How to model threads using C# thread class.
  • Control thread lifetime and coordinate thread shutdown.
  • Using thread pool to queue your work item.
  • What is thread synchronization and a race condition.
  • Thread synchronization techniques.
  • What is wait based synchronization in multithreading.
  • How to use Monitor class in C#.
  • What is task?
  • Task exectuion model.
  • Harvesting result from task.
  • Task handling techniques.
  • Exception handling in task.

Requirements

  • You will need Visual Studio IDE (for programming in C# .NET) to get started with this tutorial.
  • All demos in this tutorial are built using Visual Studio and complete solution demo is available here:

Issues

  • You can use the Comments section at the bottom of each module to ask a question or report a problem.
  • Also feel free to ask me questions by sending me a message on my Instagram account, or add me on LinkedIn!

comments powered by Disqus