コード例 #1
0
        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
                );
        }
コード例 #2
0
ファイル: RpcServer.cs プロジェクト: Indifer/Test
		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
			);
		}