資源簡介
實現了微秒級計時器,提供一個類,風格和C#自帶的定時器差不多,誤差應該在1ms以內,這玩意想要真正十分精確還是得用硬件計時器才行.
代碼片段和文件信息
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中的函數,加載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;
????????/
- 上一篇:c#+SQL server物資管理系統
- 下一篇:C#實現本機資源監控
評論
共有 條評論