internal Window MakeWindowForConnection(Connection connection) { var window = new MainWindow(); window.Connect(connection.Stream, connection.Settings); window.Show(); return window; }
internal async Task<Connection> MakeConnectionAsync(ConnectionSettings settings, int terminalCols, int terminalRows) { using (var doneEvent = new System.Threading.ManualResetEvent(false)) { var connection = new Connection(); string error = null; connection.Connected += (_sender, _e) => { Dispatcher.Invoke(() => { doneEvent.Set(); }); }; connection.Failed += (_sender, _e) => { Dispatcher.Invoke(() => { error = _e.Message; doneEvent.Set(); }); }; connection.Connect(settings, App.DefaultTerminalCols, App.DefaultTerminalRows); await Task.Run(new Action(() => doneEvent.WaitOne())); if (error != null) throw new ConnectException(error); return connection; } }