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

Local memory - C# Tutorial

From the course: Threading in C#

Start my 1-month free trial

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…

Contents