private void ThreadMethod(ThreadExPara para) { try { while (!para.Token.IsCancellationRequested) { try { if (para.WaitOne(10000)) { continue; } } catch (ObjectDisposedException) { continue; } } } catch (Exception ex) { Loger.Error(ex); } }
private void PlayLineThreadMethod(ThreadExPara threadPara) { double durationSeconds = (double)threadPara.Para * 1000; double offsetTimeMilliseconds = 0d; int interval = 100; while (!threadPara.Token.IsCancellationRequested && offsetTimeMilliseconds < durationSeconds) { threadPara.WaitOne(interval); if (this._offsetMilliseconds.HasValue) { offsetTimeMilliseconds = this._offsetMilliseconds.Value; this._offsetMilliseconds = null; } IAsyncResult asyncResult = this.BeginInvoke(new Action <double>((d) => { waveControl.UpdatePostionLine(d); }), new object[] { offsetTimeMilliseconds }); asyncResult.AsyncWaitHandle.WaitOne(); offsetTimeMilliseconds += interval; } }