Subj : Re: Thread.Sleep(5000) Problem To : comp.programming.threads From : doug Date : Tue Apr 12 2005 07:39 pm wrote in message news:1113313381.875183.284650@g14g2000cwa.googlegroups.com... >I wrote a small simple program in C# and my problem is when I run it on > my own computer it works fine and the main thread sleeps for 5000 > miliseconds. Now when I take the .exe file to a server it doesn't > sleep. > Can anybody explain this weird thing ? > > Marios Koumides > I don't know much about C#, but on most platforms*, sleep() or its equivalent can be interrupted early. It's not beyond the realms of possibility that this happens in C# too (e.g. your thread is stolen for garbage collection), and this might happen more often in a busier server environment. Do you have some kind of loop to catch exceptions, and retry if you did't sleep the entire period? Doug * other platforms off the top of my head: - *nixes can return from sleep early (e.g. after handling a signal) - java can throw InterruptedException - select(), etc. .