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
- [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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Understanding threading2m 55s
-
(Locked)
Context switching7m 12s
-
(Locked)
Thread naming2m 33s
-
(Locked)
Shared resources2m 52s
-
(Locked)
Shared resources demo7m 35s
-
(Locked)
Threads vs. processes1m 1s
-
(Locked)
Local memory2m 50s
-
(Locked)
Thread pool2m 41s
-
(Locked)
Thread pool demo9m 49s
-
(Locked)
Other threading concepts3m 27s
-
(Locked)
Exception handling4m 37s
-
-
-
-