/// <summary> /// Create a new server that listens on the given base pipe name. /// When a request comes in, it is dispatched on a separate thread /// via the IRequestHandler interface passed in. /// </summary> /// <param name="basePipeName">Base name for named pipe</param> /// <param name="handler">Handler that handles requests</param> /// <param name="serverDieTimeout"> /// The timeout in milliseconds before the server automatically dies. /// </param> public ServerDispatcher(string basePipeName, IRequestHandler handler, int serverDieTimeout) { this.basePipeName = basePipeName; this.handler = handler; this.keepAliveTimer = new KeepAliveTimer(serverDieTimeout); var _ = new AnalyzerWatcher(this); }
/// <summary> /// Create a new connection, and listen for request on a new thread. /// </summary> public Connection(NamedPipeServerStream pipeStream, IRequestHandler handler, KeepAliveTimer keepAliveTimer) { try { this.LoggingIdentifier = pipeStream.SafePipeHandle.DangerousGetHandle().ToInt32(); } catch (Exception e) { // We shouldn't fail just because we don't have a good logging identifier this.LoggingIdentifier = new Random().Next(); Log("Exception {0} while setting logging identifier; setting to {1}", e.Message, this.LoggingIdentifier); } this.pipeStream = pipeStream; this.handler = handler; this.keepAliveTimer = keepAliveTimer; }