C# More on threading, killing a thread, waiting for, or how to do a Thread.Join
In my last post I used a ThreadPool to do some work. ThreadPools are great and I use them a lot. However many times I find myself really only needing 1 thread and I need to have some control over it. I may need to wait for it to finish, or more importantly I need to be able to control when it dies or completes its task. For this case I always use Thread.Join As usual please peruse the MSDN documentation . Thread.Join waits for the thread to complete before proceeding with any other operations. So simply creating a thread then calling Thread.Join can be useful in some UI operations I tend to not call Join until I'm ready to kill the thread entirely. The MSDN link above goes over the great details. Now let's go over some quick code. This example creates a thread then waits for the user to press a key and terminates the thread. Let's look at the main console code using System; using System.Collections.Generic; using System.Text; using System.Threading; namesp...