/// <summary> /// 停止管道服务。 /// </summary> public void Stop() { if (this.state == PipeServiceState.Runing) { this.lock4State.EnterWriteLock(); try { if (this.state == PipeServiceState.Runing) { this.state = PipeServiceState.Stoped; // 立即阻止后续发送请求 this.listener.Stop(); this.listener = null; this.FireStoped(EventArgs.Empty); } } finally { this.lock4State.ExitWriteLock(); } } }
//todo: 添加一个监听线程,每隔一分钟执行一次,检查超过3分钟仍未收到数据的客户端,然后将其关闭 /// <summary> /// 启动管道服务。 /// </summary> public void Start() { if (this.state == PipeServiceState.Init) { this.lock4State.EnterWriteLock(); try { if (this.state == PipeServiceState.Init) { this.listener = new PipeServiceListener(this, this.pipeName); this.listener.Start(); this.state = PipeServiceState.Runing; this.FireStarted(EventArgs.Empty); } } finally { this.lock4State.ExitWriteLock(); } } }