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.
Local memory
- [Instructor] We're back to Visual Studio. We're going to create a new project. This one is going to show you how we have local copies of objects in memory. Again, it's a console app. We're going to start a new thread. Again, use Control + dot to use System.Threading, and then something simple like print one to 30. We can resolve this by using Control + dot, and have Visual Studio create the method. At this point, all we need to do is something very simple like int i is zero all the way 'til 30, and I want to print zero to 29. Then I can say, Console.Write, print i. Maybe I want to say, i plus one so I can print one to 30. This should do it. I can do the same exact thing using the main thread. As you notice, this is more like a shortcut to spawn off a new thread and start it. And this is the worker thread, and here's the main thread doing the same exact thing, printing one to 30. Now, as we talked about, I'm going to do Control + K + D so it's a little bit better formatted. This…
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
-
-
-
-