From the course: Threading in C#

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Context switching

Context switching - C# Tutorial

From the course: Threading in C#

Start my 1-month free trial

Context switching

- [Instructor] Let's look at some examples so we can understand how Threading works. Once you go to Visual Studio, click File, New Project, Visual C#, Windows Classic Desktop. And then you can pick the Console App. First thing we'll look at is going to be Context Switching, press OK. In order to create a Thread, the first thing we need to do is incorporate the Thread class. You can use control dot or you can also right-click right here and resolve the reference. So once you say Quick Actions, it will point to here. You can say, using System.Threading. Right here, you're going to use the name of the method that will give the program sequence of instructions to this particular Thread whenever this Thread is being spawned off. And this could be any method you like. I'm going to call it WriteUsingNewThread because this will spawn off a completely new Thread. Now either you can create a method or you can come here and use the same exact key combination which is control dot and generate a…

Contents