首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

Thread.sleep() 为何暂停时间不对

2013-08-24 
Thread.sleep() 为什么暂停时间不对?我用Thread.sleep(2000),要暂停程序2秒钟,可是我发现暂停的时间根本没

Thread.sleep() 为什么暂停时间不对?
我用Thread.sleep(2000),要暂停程序2秒钟,可是我发现暂停的时间根本没有2秒,有的时候很快就到了。我把时间设置大点,如5000毫秒,还是一样的。这是怎么回事?如精确的控制暂停的时间呢?
[解决办法]

Thread.CurrentThread.Join(2000);

[解决办法]
lz看看这个帖子:

What Thread sleep method is most precise: Monitor.Wait vs System.Timer vs DispatchTimer vs Threading.Timer
http://stackoverflow.com/questions/10609718/what-thread-sleep-method-is-most-precise-monitor-wait-vs-system-timer-vs-dispat

How accurate is Thread.Sleep(TimeSpan)?
http://stackoverflow.com/questions/1303667/how-accurate-is-thread-sleeptimespan

热点排行