public void Connect() { if (IsConnected) { // We are already connected return; } // Do the connection on a separate thread to make sure we are not blocking the UI while connecting var connectionThread = new Thread(() => { _fileClient = new FileServiceClientHost(); _fileClient.Connect(Hostname, Port); _testClient = new TestServiceClientHost(); _testClient.Connect(Hostname, Port); _testClient.OutputReceived += _testClient_OutputReceived; _isRunning = true; StartMonitoringConnectionStatus(); }); connectionThread.IsBackground = true; connectionThread.Start(); }
private void btnConnect_Click(object sender, EventArgs e) { _fileClient = new FileServiceClientHost(); _fileClient.Connect(txtHostname.Text, 9123); _testClient = new TestServiceClientHost(); _testClient.OutputReceived += TestClientOnOutputReceived; _testClient.Connect(txtHostname.Text, 9123); txtHostname.Enabled = btnConnect.Enabled = _fileClient.State != Services.ConnectionState.Online && _testClient.State != Services.ConnectionState.Online; pnlMain.Enabled = !txtHostname.Enabled; AcceptButton = btnRun; }