public virtual int CfRunLoop() { this.CfIsRunning = true; try { //三個方法(三個保護)控管執行 while (!disposed && this.CfIsRunning) { if (taskRun != null) { if (this.taskRun.CancelToken.IsCancellationRequested) { break; } this.taskRun.CancelToken.ThrowIfCancellationRequested();//一般cancel task 在 while 和 第一行 } this.CfRunOnce(); } CtkLog.Info("Finish SensorDevice"); } catch (Exception ex) { CtkLog.Write(ex, CtkLoggerEnumLevel.Error); } return(0); }