需要使用c#准确替代Thread.sleep(时间) [英] Need a accurate alternative of Thread.sleep(time) using c#

查看:1003
本文介绍了需要使用c#准确替代Thread.sleep(时间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI

我正在开发工程应用程序,我们需要多次执行thread.sleep()函数。但是由于睡眠间隔不准确,我们需要一个可以模仿thread.sleep()功能的替代方案。


我们的代码中有多媒体计时器所以请知道我是否可以使用它在某种程度上为此目的。


任何帮助将不胜感激。

解决方案

Thread.Sleep是什么意思( )间隔不准确?

它以毫秒为单位计算时间,这与基于Windows的PC一样准确。 (有办法尝试做更小的定时器间隔,但Windows PC上系统时钟的分辨率通常只有几毫秒......根据msdn)


hi

我的意思是说thread.sleep(10)可以暂停当前线程超过10毫秒,而我希望它暂停线程10毫秒。因为我的应用程序非常关键时间。



i看你的意思。

i做了一个控制台应用来测试它

展开 | 选择 | Wrap | 行号

HI
I am working on Engineering application where we need thread.sleep() function many times. But since sleep interval is not accurate we need an alternative which can mimick functionality of thread.sleep() .

we have multimedia timer in our code so Please lemme know if I can use that in someway for this purpose.

Any Help would be greatly appreciated.

解决方案

What do mean by Thread.Sleep() interval is not accurate?
It meaures it''s time in miliseconds, which is as accurate as a windows-based PC can get. (There ways to try and do smaller timer intervals, but the resolutions of system clocks on windows PCs is generally only a milisecond...according to msdn)


hi
what I mean to say is that thread.sleep(10) can pause current thread for more than 10 milliseconds whereas I want it to to pause thread for exactly for 10 milliseconds.since my application is very much time critical.


Hi,
i see what you mean.
i made a console app to test it

Expand|Select|Wrap|Line Numbers


这篇关于需要使用c#准确替代Thread.sleep(时间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆