[EDIT] made main window open only when the client has connected

This commit is contained in:
Sem van der Hoeven
2020-10-20 18:27:53 +02:00
parent f6c70bc717
commit 73dc0b94de
3 changed files with 14 additions and 6 deletions

View File

@@ -28,13 +28,18 @@ namespace Client.Views
{
User user = new User(usernameTextbox.Text);
Client client = new Client(user.Username);
client.OnSuccessfullConnect = () =>
{
// because we need to start the main window on a UI thread, we need to let the dispatcher handle it, which will execute the code on the ui thread
Application.Current.Dispatcher.Invoke(delegate {
data.User = user;
data.Client = client;
MainWindow startWindow = new MainWindow();
startWindow.Show();
this.Close();
});
};
data.User = user;
data.Client = client;
MainWindow startWindow = new MainWindow();
startWindow.Show();
this.Close();
}
}
}