/// <summary>
        /// Stop the listener thread
        /// </summary>
        public void Stop()
        {
            // Request the listener thread to stop
            StopRequested = true;

            // Wait for termination
            ListenerThread.Join(1000);
        }
示例#2
0
 /// <summary>
 /// Stops the server and ends all associated threads
 /// </summary>
 public void Stop()
 {
     StopEvent.Set();
     ListenerThread.Join();
     foreach (Thread worker in WorkerThreads)
     {
         worker.Join();
     }
     Listener.Stop();
 }
        /// <summary>
        /// Stop the listener thread
        /// </summary>
        public void Stop()
        {
            // Resume copying to allow buffers to flush
            ResumeCopying();

            // Request the listener thread to stop
            StopRequested = true;

            // Wait for termination
            ListenerThread.Join(1000);
        }
示例#4
0
        /// <summary>
        /// Stops the Proxy Server, removes the Windows proxy settings, and cleans up the thread.
        /// </summary>
        public void Stop()
        {
            // remove the proxy
            this.SetProxy(false);

            //stop listening for incoming connections
            Listener.Stop();

            //wait for server to finish processing current connections...
            ListenerThread.Abort();
            ListenerThread.Join();
        }
示例#5
0
        /// <summary>
        /// Stop the listener thread
        /// </summary>
        public void Stop()
        {
            // Request the listener thread to stop
            StopRequested = true;

            // A copy of the list of connections to avoid locking
            IList <T> unlockedConnections = new List <T>();

            // Synchronize access to connections collection
            lock (Connections)
            {
                // Iterate over all connections and copy into the local list
                foreach (T connection in Connections)
                {
                    unlockedConnections.Add(connection);
                }
            }

            // Iterate over all connections and request each one to stop
            foreach (T connection in unlockedConnections)
            {
                // Request to stop
                connection.Stop();
            }

            // If server failed to start there is no thread to join
            if (ListenerThread != null)
            {
                // Wait for termination
                ListenerThread.Join();
            }

            // If server failed to start there is no listener associated with it
            if (ListenerSocket != null)
            {
                // Stop the server
                ListenerSocket.Stop();
                ListenerSocket = null;
            }
        }
示例#6
0
 private void JoinListener()
 {
     ListenerThread.Join();
 }