public Duration() { if (DurationMethods.QueryPerformanceFrequency(out _Freq) == false) { throw new Win32Exception(); } }
/// <summary> /// 开始计时器 /// </summary> public bool Start() { if (this.RunFlag) { return(false); } this.RunFlag = true; Thread.Sleep(0); this.Begin = DateTime.Now; DurationMethods.QueryPerformanceCounter(out _StartTime); return(true); }
/// <summary> /// 停止计时器 /// </summary> public bool Stop() { if (!this.RunFlag) { return(false); } this.RunFlag = false; this.End = DateTime.Now; DurationMethods.QueryPerformanceCounter(out _StopTime); this._DurationValue = (double)(_StartTime - _StopTime) / (double)_Freq * 1000; return(true); }