From the course: Threading in C#

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Other threading concepts

Other threading concepts - C# Tutorial

From the course: Threading in C#

Other threading concepts

- [Lecturer] We're back to Visual Studio to cover some of the concepts that are important when it comes to threading. So let's start by creating a thread. And something very simple like PrintHelloWorld. We can resolve it using Control dot to get a method. And it could do anything, but for now we'll just do a very small running process. Now imagine that this process actually took, for example, let's say five seconds. So we're going to say Thread.Sleep, five seconds. And we can come here and start the thread. That means the first thing that happens is, a worker thread gets pawned off, prints Hello World and then waits five seconds. Well now, once this is done, we want to say something like Console.WriteLine, Hello World printed. And let's do Control F5. As you can see, Hello World printed will get printed before Hello World and then we have Hello World and then five seconds later the application stopped and now I can press any key to continue. So there are times like that, when even…

Contents