private bool ConnectToPipe() { for (int i = 0; i < ConnectionRetries; i++) { try { var binding = new NetNamedPipeBinding { OpenTimeout = TimeSpan.FromSeconds(10), CloseTimeout = TimeSpan.FromSeconds(10), SendTimeout = TimeSpan.FromSeconds(10), ReceiveTimeout = TimeSpan.FromSeconds(10) }; this.pipeFactory = new DuplexChannelFactory <IHandBrakeEncoder>( this, binding, new EndpointAddress("net.pipe://localhost/" + this.pipeName)); this.channel = this.pipeFactory.CreateChannel(); this.channel.Ping(); return(true); } catch (EndpointNotFoundException) { } if (this.worker.HasExited) { List <LogEntry> logs = this.GetWorkerMessages(); int errors = logs.Count(l => l.LogType == LogType.Error); this.logger.LogError("Worker exited before a connection could be established."); if (errors > 0) { this.logger.Log(logs); } return(false); } Thread.Sleep(ConnectionRetryIntervalMs); } this.logger.LogError("Connection to worker failed after " + ConnectionRetries + " retries. Unable to find endpoint."); this.LogAndClearWorkerMessages(); return(false); }
private bool ConnectToPipe() { for (int i = 0; i < ConnectionRetries; i++) { try { var binding = new NetNamedPipeBinding { OpenTimeout = TimeSpan.FromSeconds(10), CloseTimeout = TimeSpan.FromSeconds(10), SendTimeout = TimeSpan.FromSeconds(10), ReceiveTimeout = TimeSpan.FromSeconds(10) }; this.pipeFactory = new DuplexChannelFactory<IHandBrakeEncoder>( this, binding, new EndpointAddress("net.pipe://localhost/" + this.pipeName)); this.channel = this.pipeFactory.CreateChannel(); this.channel.Ping(); return true; } catch (EndpointNotFoundException) { } if (this.worker.HasExited) { List<LogEntry> logs = this.GetWorkerMessages(); int errors = logs.Count(l => l.LogType == LogType.Error); this.logger.LogError("Worker exited before a connection could be established."); if (errors > 0) { this.logger.Log(logs); } return false; } Thread.Sleep(ConnectionRetryIntervalMs); } this.logger.LogError("Connection to worker failed after " + ConnectionRetries + " retries. Unable to find endpoint."); this.LogAndClearWorkerMessages(); return false; }