如何使用CreateTimerQueueTimer建立在C#中高分辨率计时器? [英] How can I use CreateTimerQueueTimer to create a high resolution timer in C#?

查看:1477
本文介绍了如何使用CreateTimerQueueTimer建立在C#中高分辨率计时器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用一个Windows与多媒体

I've used a Windows multimedia dll to created a high resolution timer with

timSetEvent()

的timeSetEvent()页建议使用:

CreateTimerQueueTimer()

我如何使用CreateTimerQueueTimer()来在C#中执行一个方法每隔10毫秒?

How can I use CreateTimerQueueTimer() to execute a method every 10 milliseconds in C#?

推荐答案

下面是一个C#包装的链接 CreateTimerQueueTimer

Here is a link to a C# wrapper for CreateTimerQueueTimer:

http://social.msdn.microsoft.com/Forums/en-CA/csharpgeneral/thread/822aed2d-dca0-4a8e-8130-20fab69557d2

(向下滚动到最后发表 Hobz 为样本类)

(scroll down to the last post by Hobz for the sample class)

我只是尝试了这一点,我和它工作正常。有一件事你需要添加,虽然是通话timeBeginPeriod(1)为您的系统设置为高分辨率启动定时器之前。 的timeSetEvent 要求 timeBeginPeriod 内部,这就是为什么有些人误以为它创建了一个更高分辨率的定时器。

I just tried this out myself and it works fine. One thing you'll need to add, though, is a call to timeBeginPeriod(1) before starting the timer in order to set your system to high-resolution. timeSetEvent calls timeBeginPeriod internally, which is why some people mistakenly assume that it creates a higher-resolution timer.

这篇关于如何使用CreateTimerQueueTimer建立在C#中高分辨率计时器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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