protected override void Stop() { if (_stopFlag == 1) { return; } _cancellation.Cancel(); Thread.MemoryBarrier(); ModuleUtils.StopThreadWork(_receiveThread); //如果两个队列在被锁的状态则释放锁 _engineMessageQueue.FreeBlocks(); _statusMessageQueue.FreeBlocks(); _callBackMessageQueue.FreeBlocks(); // 发送停止消息,该消息只是为了释放被Receive阻塞的线程,并不会真的被处理 ControlMessage stopMessage = new ControlMessage(MessageNames.CtrlAbort, CommonConst.BroadcastSession); UpLinkMessenger.Send(stopMessage); Thread.MemoryBarrier(); ModuleUtils.StopThreadWork(_engineMessageListener); ModuleUtils.StopThreadWork(_statusMessageListener); ModuleUtils.StopThreadWork(_callBackMessageListener); ModuleUtils.StopThreadWork(_receiveThread); ZombieCleaner.Stop(); UpLinkMessenger.Clear(); Thread.VolatileWrite(ref _stopFlag, 1); GlobalInfo.LogService.Print(LogLevel.Info, CommonConst.PlatformLogSession, "Message transceiver stopped."); }
protected override void Stop() { _cancellation.Cancel(); ModuleUtils.StopThreadWork(_receiveThread); //如果两个队列在被锁的状态则释放锁 _engineMessageQueue.FreeLock(); _statusMessageQueue.FreeLock(); ModuleUtils.StopThreadWork(_engineMessageListener); ModuleUtils.StopThreadWork(_statusMessageListener); ZombieCleaner.Stop(); }