Beispiel #1
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         Shutdown();
         _listenerThread.Join();
         _listener = null;
         if (_threadPool != null)
         {
             _threadPool.Join();
             _threadPool.Dispose();
             _threadPool = null;
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Creates a WebServer that runs on the specified port and can be multithreaded
 /// </summary>
 /// <param name="port">
 /// The port on which to run the server (default 80)
 /// </param>
 /// <param name="threadPoolSize">
 /// The maximum number of threads to be created.
 /// CustomThreadPool.DefaultThreadPoolSize means use default operating system value.
 /// </param>
 /// <param name="priority">
 /// The priority of the web server threads.
 /// </param>
 /// <remarks>
 /// A server must be multithreaded in order to use the Keep-Alive HTTP mechanism.
 /// </remarks>
 public WebServer(int port = DefaultPortHttp, int threadPoolSize = CustomThreadPool.DefaultThreadPoolSize, ThreadPriority priority = DefaultThreadPriority)
 {
     Port = port;
     PreRouteProcessors = new List <PreRouteProcessor>();
     Routes             = new RouteSolver();
     Routes.Error      += _routeSolver_Error;
     _openTcpClients    = new List <TcpClient>();
     _listener          = new TcpListener(IPAddress.Any, port);
     if (threadPoolSize == CustomThreadPool.DefaultThreadPoolSize || threadPoolSize > 1)
     {
         _threadPool = new CustomThreadPool("WoopsaWebServer", threadPoolSize, priority);
     }
     _listenerThread          = new Thread(Listen);
     _listenerThread.Priority = priority;
     _listenerThread.Name     = "WebServer_Listener";
     HTTPResponse.Error      += HTTPResponse_Error;
 }
Beispiel #3
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                Shutdown();
                _listenerThread.Join();
                _listener = null;
                if (_threadPool != null)
                {
                    _threadPool.Join();
                    _threadPool.Dispose();
                    _threadPool = null;
                }

            }
        }
Beispiel #4
0
 /// <summary>
 /// Creates a WebServer that runs on the specified port and can be multithreaded
 /// </summary>
 /// <param name="port">
 /// The port on which to run the server (default 80)
 /// </param>
 /// <param name="threadPoolSize">
 /// The maximum number of threads to be created. 
 /// CustomThreadPool.DefaultThreadPoolSize means use default operating system value.
 /// </param>
 /// <param name="priority">
 /// The priority of the web server threads.
 /// </param>
 /// <remarks>
 /// A server must be multithreaded in order to use the Keep-Alive HTTP mechanism.
 /// </remarks>
 public WebServer(int port = DefaultPortHttp, int threadPoolSize = CustomThreadPool.DefaultThreadPoolSize, ThreadPriority priority = DefaultThreadPriority)
 {
     Port = port;
     PreRouteProcessors = new List<PreRouteProcessor>();
     Routes = new RouteSolver();
     Routes.Error += _routeSolver_Error;
     _openTcpClients = new List<TcpClient>();
     _listener = new TcpListener(IPAddress.Any, port);
     if (threadPoolSize == CustomThreadPool.DefaultThreadPoolSize || threadPoolSize > 1)
         _threadPool = new CustomThreadPool("WoopsaWebServer", threadPoolSize, priority);
     _listenerThread = new Thread(Listen);
     _listenerThread.Priority = priority;
     _listenerThread.Name = "WebServer_Listener";
     HTTPResponse.Error += HTTPResponse_Error;
 }