/// <summary> /// TCP 客户端套接字初始化处理 /// </summary> /// <param name="socket"></param> private void onClientSocket(AutoCSer.Net.TcpServer.ClientSocketBase socket) { Abstract.QueueConsumerStreamProcessor oldProcesser = Processor; if (socket != null) { createProcessor(); } else { Processor = null; } if (oldProcesser != null) { oldProcesser.Free(); } }
/// <summary> /// 重启处理器 /// </summary> /// <param name="processor"></param> internal void ReStartProcessor(QueueConsumerStreamProcessor processor) { if (IsProcessor(processor)) { object setSocketLock = client._TcpClient_.SetSocketLock; Monitor.Enter(setSocketLock); try { if (IsProcessor(processor)) { Processor = null; reStartProcessor(); } } finally { Monitor.Exit(setSocketLock); } } processor.Free(); }
internal bool IsProcessor(QueueConsumerStreamProcessor processor) { return(ReferenceEquals(Processor, processor) && isDisposed == 0); }