Bracket.Hosting.SystemWeb.SimpleWebServer.Start C# (CSharp) Méthode

Start() public méthode

public Start ( ) : void
Résultat void
        public virtual void Start()
        {
            if (_connectionManagerThread == null || _connectionManagerThread.ThreadState == ThreadState.Stopped)
            {
                _connectionManagerThread = new Thread(ConnectionManagerThreadStart)
                                               {
                                                   Name =
                                                       String.Format(CultureInfo.InvariantCulture,
                                                                     "ConnectionManager_{0}", UniqueId)
                                               };
            }
            else if (_connectionManagerThread.ThreadState == ThreadState.Running)
            {
                throw new ThreadStateException("The request handling process is already running.");
            }

            if (_connectionManagerThread.ThreadState != ThreadState.Unstarted)
            {
                throw new ThreadStateException("The request handling process was not properly initialized so it could not be started.");
            }
            _connectionManagerThread.Start();

            long waitTime = DateTime.Now.Ticks + TimeSpan.TicksPerSecond * 10;
            while (RunState != State.Started)
            {
                Thread.Sleep(100);
                if (DateTime.Now.Ticks > waitTime)
                {
                    throw new TimeoutException("Unable to start the request handling process.");
                }
            }
        }

Usage Example

 public void Start(RubyEnvironment rubyEnvironment)
 {
      _rack = new Rack(rubyEnvironment);
     _server = new SimpleWebServer(_listeningUris);
     _server.RequestHandlingError += RequestProcessingError;
     _server.IncomingRequest += ProcessRequest;
     _server.Start();
 }