private void Stop() { var currentDispatcher = Interlocked.Exchange(ref this._dispatcher, null); if (currentDispatcher == null) { return; } if (Interlocked.Exchange(ref _state, 1) != 0) { return; } if (this._transportManager != null) { using (var tracker = new ShutdownTracker()) { this._transportManager.ShutdownCompleted += tracker.OnTransportManagerShutdownCompleted; try { if (this._transportManager.BeginShutdown()) { tracker.Wait(); } } finally { this._transportManager.ShutdownCompleted -= tracker.OnTransportManagerShutdownCompleted; } } this._transportManager.Dispose(); this._transportManager = null; } MsgPackRpcServerTrace.TraceEvent( MsgPackRpcServerTrace.StopServer, "Stop server. {{ \"Configuration\" : {0}, \"Id\" : \"{1}\" }}", this._configuration, this ); }
private void Stop() { var currentDispatcher = Interlocked.Exchange( ref this._dispatcher, null ); if ( currentDispatcher == null ) { return; } if ( Interlocked.Exchange( ref _state, 1 ) != 0 ) { return; } if ( this._transportManager != null ) { using ( var tracker = new ShutdownTracker() ) { this._transportManager.ShutdownCompleted += tracker.OnTransportManagerShutdownCompleted; try { if ( this._transportManager.BeginShutdown() ) { tracker.Wait(); } } finally { this._transportManager.ShutdownCompleted -= tracker.OnTransportManagerShutdownCompleted; } } this._transportManager.Dispose(); this._transportManager = null; } MsgPackRpcServerTrace.TraceEvent( MsgPackRpcServerTrace.StopServer, "Stop server. {{ \"Configuration\" : {0}, \"Id\" : \"{1}\" }}", this._configuration, this ); }