当前位置: 首页 > news >正文

.Net CF下精确的计时器

.Net CF下精确的计时器
用法:
Dim t as New AtomicCF.Timer
t.start()
....'Some functions here
Dim TimeLapsed as Long = t.stop()

None.gif Imports  System.Runtime.InteropServices
ExpandedBlockStart.gifContractedBlock.gif
Namespace AtomicCF Namespace AtomicCF
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Class TimerClass Timer
InBlock.gif        
<DllImport("coredll.dll", EntryPoint:="QueryPerformanceCounter")> _
ExpandedSubBlockStart.gifContractedSubBlock.gif        
Public Shared Function QueryPerformanceCounter()Function QueryPerformanceCounter(ByRef perfCounter As LongAs Integer
ExpandedSubBlockEnd.gif        
End Function

InBlock.gif
InBlock.gif        
<DllImport("coredll.dll", EntryPoint:="QueryPerformanceFrequency")> _
ExpandedSubBlockStart.gifContractedSubBlock.gif        
Public Shared Function QueryPerformanceFrequency()Function QueryPerformanceFrequency(ByRef frequency As LongAs Integer
ExpandedSubBlockEnd.gif        
End Function

InBlock.gif
InBlock.gif        
Private m_frequency As Int64
InBlock.gif        
Private m_start As Int64
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
Public Sub New()Sub New()
InBlock.gif            
If QueryPerformanceFrequency(m_frequency) = 0 Then
InBlock.gif                
Throw New ApplicationException
InBlock.gif            
End If
InBlock.gif            
'Convert to ms.
InBlock.gif
            m_frequency = CLng(m_frequency / 1000)
ExpandedSubBlockEnd.gif        
End Sub

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
Public Sub Start()Sub Start()
InBlock.gif            
If QueryPerformanceCounter(m_start) = 0 Then
InBlock.gif                
Throw New ApplicationException
InBlock.gif            
End If
ExpandedSubBlockEnd.gif        
End Sub

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
Public Function [()Function [Stop]() As Int64            Dim lStop As Int64 = 0            If QueryPerformanceCounter(lStop) = 0 Then                Throw New ApplicationException            End If            Return CLng((lStop - m_start) / m_frequency)        End Function    End ClassEnd Namespace Namespace
InBlock.gif

相关文章:

  • SSH 正向/反向代理小记
  • 寻求最快解决方案
  • [MAT]使用MAT比較多个heap dump文件
  • nagios 主机状态
  • FZU 1692 Key problem (构造矩阵)
  • 【分享】通过Excel生成批量SQL语句,处理大量数据的好办法
  • SGU 122 The book(构造)
  • 全局dialog,在小米4及部分机型上不能正常弹出
  • DOM常用操作
  • docker学习笔记7:发布镜像到docker hub上
  • Java通过wait()和notifyAll()方法实现线程间的通信
  • Ado.NET SQLHelper
  • ubuntu14.04 忘记root密码
  • 神奇语言python文件操作
  • Microsoft SQL Server登陆Linux
  • (三)从jvm层面了解线程的启动和停止
  • axios 和 cookie 的那些事
  • Codepen 每日精选(2018-3-25)
  • LeetCode18.四数之和 JavaScript
  • PV统计优化设计
  • python docx文档转html页面
  • Python 基础起步 (十) 什么叫函数?
  • 案例分享〡三拾众筹持续交付开发流程支撑创新业务
  • 成为一名优秀的Developer的书单
  • 关于extract.autodesk.io的一些说明
  • 白色的风信子
  • ​软考-高级-系统架构设计师教程(清华第2版)【第12章 信息系统架构设计理论与实践(P420~465)-思维导图】​
  • # 日期待t_最值得等的SUV奥迪Q9:空间比MPV还大,或搭4.0T,香
  • #vue3 实现前端下载excel文件模板功能
  • #微信小程序(布局、渲染层基础知识)
  • (02)Hive SQL编译成MapReduce任务的过程
  • (13):Silverlight 2 数据与通信之WebRequest
  • (4)事件处理——(6)给.ready()回调函数传递一个参数(Passing an argument to the .ready() callback)...
  • (附源码)springboot炼糖厂地磅全自动控制系统 毕业设计 341357
  • (十二)python网络爬虫(理论+实战)——实战:使用BeautfulSoup解析baidu热搜新闻数据
  • (四)鸿鹄云架构一服务注册中心
  • (五)Python 垃圾回收机制
  • (转)GCC在C语言中内嵌汇编 asm __volatile__
  • (转)创业家杂志:UCWEB天使第一步
  • (转)详解PHP处理密码的几种方式
  • ./configure,make,make install的作用
  • .cfg\.dat\.mak(持续补充)
  • .FileZilla的使用和主动模式被动模式介绍
  • .NET core 自定义过滤器 Filter 实现webapi RestFul 统一接口数据返回格式
  • .NET/C# 解压 Zip 文件时出现异常:System.IO.InvalidDataException: 找不到中央目录结尾记录。
  • .net开发引用程序集提示没有强名称的解决办法
  • .NET项目中存在多个web.config文件时的加载顺序
  • .net中调用windows performance记录性能信息
  • /proc/stat文件详解(翻译)
  • @Service注解让spring找到你的Service bean
  • [ C++ ] 继承
  • [c++] 什么是平凡类型,标准布局类型,POD类型,聚合体
  • [C++]类和对象【下】
  • [cocos creator]EditBox,editing-return事件,清空输入框
  • [github全教程]github版本控制最全教学------- 大厂找工作面试必备!