Bracket.Hosting.SystemWeb.SimpleWebServer.Stop C# (CSharp) Method

Stop() public method

public Stop ( ) : void
return void
        public virtual void Stop()
        {
            // Setting the runstate to something other than "started" and
            // stopping the listener should abort the AddIncomingRequestToQueue
            // method and allow the ConnectionManagerThreadStart sequence to
            // end, which sets the RunState to Stopped.
            Interlocked.Exchange(ref _runState, (long)State.Stopping);
            if (_listener.IsListening)
            {
                _listener.Stop();
            }
            long waitTime = DateTime.Now.Ticks + TimeSpan.TicksPerSecond * 10;
            while (RunState != State.Stopped)
            {
                Thread.Sleep(100);
                if (DateTime.Now.Ticks > waitTime)
                {
                    throw new TimeoutException("Unable to stop the web server process.");
                }
            }

            _connectionManagerThread = null;
        }
    }