public void ThreadMQRouterSend() { try { using (RouterSocket routerSocket = new RouterSocket()) { routerSocket.Bind(MQConfig.RouterSendServer); while (!_cancellationTokenSource.IsCancellationRequested) { try { IdKeyData item; if (MQRouterSendQueue.TryTake(out item)) { routerSocket.RouterSend(item); } } catch (TerminatingException) { } catch (Exception ex) { MQThreadExceptionHandler?.Invoke(ex); } } } } catch (Exception ex) { MQThreadExceptionHandler?.Invoke(ex); } }