-
大小: 2KB文件類型: .cs金幣: 1下載: 0 次發(fā)布日期: 2021-05-09
- 語言: C#
- 標(biāo)簽: 微秒??計(jì)時(shí)器??C#??
資源簡介
實(shí)現(xiàn)了微秒級計(jì)時(shí)器,提供一個(gè)類,風(fēng)格和C#自帶的定時(shí)器差不多,誤差應(yīng)該在1ms以內(nèi),這玩意想要真正十分精確還是得用硬件計(jì)時(shí)器才行.
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Runtime.InteropServices;
using?System.Text;
using?System.Threading.Tasks;
using?System.Timers;
using?System.Threading;
using?System.IO;
namespace?usTimer
{
????//使用windows.h中的函數(shù),加載DLL來使用
????public?static?class?QueryPerformanceMethd
????{
????????[DllImport(“kernel32.dll“)]
????????public?extern?static?short?QueryPerformanceCounter(ref?long?x);
????????[DllImport(“kernel32.dll“)]
????????public?extern?static?short?QueryPerformanceFrequency(ref?long?x);
????}
????public?class?usTimerEventArgs?:?EventArgs
????{
????????public?double?Timenow?=?0;
????????public?usTimerEventArgs(double?inputTime)
????????{
????????????Timenow?=?inputTime;
????????}
????}
????public?delegate?void?ElapsedEvent(object?Sender?usTimerEventArgs?e);
????class?usTimer
????{
????????long?stop_Value?=?0;
????????long?start_Value?=?0;
????????long?freq?=?0;
????????double?time?=?0;
????????bool?stop?=?true;
????????/
評論
共有 條評論