1 Star 1 Fork 3

电脑程序爱好者/一个.NET 高精度Timer(毫秒级)

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

一个.NET 高精度Timer

很多时候,我们需要是比c#和Windows(一般在15ms 左右)精度更高的定期间隔事件,但是却受限制Windows操作系统内建的标准计时器机制。
Window确实存在一个用于多媒体应用程序的高精度定时api,但这些api并没有公开在.net api中。
但是对于需要1ms量级的计时器精度的应用程序,这些api非常有用。
本库封装了Multimedia Timer API(http://msdn.microsoft.com/en-us/library/windows/desktop/dd743609(v=vs.85).aspx)。
需要说明的是,这个API改变了系统的设置,可能会降低系统性能(尤其是电池寿命),所以使用者要当心。
还有因为Windows不是一个实时的操作系统,在你的系统上的负载也可能会导致本定时器延迟。
假如间隔为100毫秒,包含快速连续的100个事件,其得到的结果可能不是间隔1毫秒的100个事件。
另外.NET线程调度,GC回收,运行时编译都可能导致延迟出现。 其他的资料[毫秒定时器]参照(https://blogs.msdn.microsoft.com/mediasdkstuff/2009/07/02/why-are-the-multimedia-timer-apis-timesetevent-not-as-accurate-as-i-would-expect/)。

MIT License Copyright (c) 2016 Mike Zboray Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一个.NET 高精度Timer(毫秒级) 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tm2002/high-precision-timer.git
git@gitee.com:tm2002/high-precision-timer.git
tm2002
high-precision-timer
一个.NET 高精度Timer(毫秒级)
master

搜索帮助