What do you WANT to happen? Once a thread is started, it shouldn't be blocking the UI.
public void button_Click(...)
{
Thread thread = new Thread(new ThreadStart(ThreadProc));
thread.Start();
}
public void ThreadStart()
{
}
Even if you use a BackgroundWorker objec, it should run without blocking the UI.
If you need the thread to update the UI as it's running, that's simple ennough.
BTW, your first example is going to start the thread, and then sleep the UI for 5 seconds.
Further, why use a thread if you're going to use
Join
? You should use Join to couple threads together so that one thread doesn't finish until the joined thread is also finished.
It looks like you don't have a firm grasp of how threading works in .Net.