I’m starting a Thread that runs routine tasks with some Files, unfortunately, calling Thread.Sleep inside that thread callback hangs up Windows for the specified time, ie. my cursor freezes and CTRL+ALT+DEL does nothing either. How do I specifically “Sleep” the background thread without hanging up the UI?
I’m creating the thread using this:
createThread = new Thread(new ThreadStart(this.createFileExec));
createThread.Start();
And my callback is like this:
private void createFileExec() {
....
Thread.Sleep(100);
....
}
That’s exactly what you are doing by calling
Thread.Sleepon your new thread. Are you sure you aren’t callingcreateFileExecfrom the main thread?