/// <summary> /// 心跳线程 /// </summary> private void TickThread() { var token = _cancellationTokenSource.Token; while (true) { if (token.IsCancellationRequested) { break; } DeviceCommunication cur = null; lock (_communicationListLock) { if (_communicationList.Count > 0) { cur = _communicationList.Dequeue(); } } if (cur != null) { cur.DoTick(); } // System.Threading.Thread.Sleep(10); } }