Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
What is Threading? | Threading
Advanced C# with .NET
course content

Зміст курсу

Advanced C# with .NET

Advanced C# with .NET

1. Introduction to Desktop Development with .NET
2. Interactive GUI
3. Threading
4. Generics & Reflection

bookWhat is Threading?

In terms of C# programming, a "Thread" refers to a queue of operations. The operations which we write in code are all typically enqueued into a single thread, which are then executed one by one by the program.

So far, most of the programs we made, including the GUI based applications, were essentially running on a single Main Thread, which is responsible for executing the main operations of the program.

However, in some applications, it is imperative to be able to execute multiple operations at same time. This can be done by manually creating new Threads and executing methods via those threads, in parallel to the Main Thread.

One good example where threading is required is web browsers. The web browsers which we typically use are made to support multiple operations at one time. You can open as many tabs as you want, each of which could be performing some operations in the background. For-example, you could be playing some video on one tab and browsing a website on another tab smoothly without any blockages.

In certain kinds of programs, it is essential for the computer to complete one task (or operation) before moving onto the next because the operation of the one task depends on the result of the previous task. However, in a lot of the programs we write, we can potentially face a blockage due to the program being executed on a single thread. For-example, we can have 4 different time intensive tasks which need to be performed efficiently. If we execute those tasks normally, it would result into a long execution time, and it would also block the program from doing anything else during that time:

In a lot of such cases, the user's computer has enough CPU and Memory resources to perform all of the tasks at the same time but the way the program is written causes it to take more time to complete the tasks.

We can use Multi-Threading to distribute the tasks into 4 different threads, and execute them all concurrently, hence saving a lot of time:

In the next chapter we will look at how we can execute methods on different threads.

What is Multi-Threading in C#?

What is Multi-Threading in C#?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 1
We're sorry to hear that something went wrong. What happened?
some-alt