Reviewing Threads in C#
Review of multi-threaded C# applications. The oldest way to create a Windows thread uses the Thread object. public static class Program { Thread thread = new Thread(MethodCalledInThread); thread.Start(); thread.Join(); } public static void MethodCalledInThread() { Thread.Sleep(1000); } The Start method fires off the thread and the Join method waits until the thread is done. The Sleep method just waits for the number of milliseconds in the parameter. By the way, don't ever do it this way . Take a look at async / await which is usually the way to go. However, this is a review of using multi-threading in c#, so we march onward. Foreground versus Background Threads A process always continues to run as long as there is at least one foreground thread running in the process. When there are not foreground threads running, then all background threads are forcibly terminated. Threads created using the Thread object above are foreground threads by default. Y