private void loginButton_OnClick(object sender, RoutedEventArgs e) { using (var rcon = RCONClient.INSTANCE) { try { rcon.setupStream( _vmLogin.IPAddress, _vmLogin.Port, passwordBox.Password); passwordBox.Password = string.Empty; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } ConsoleWindow consoleWindow = new ConsoleWindow(rcon); this.Visibility = Visibility.Collapsed; consoleWindow.ShowDialog(); this.Visibility = Visibility.Visible; } }