private void HandlerGameCreatedMessage(CreateGameMessage createGameMessage) { Application.Current.Dispatcher.Invoke(delegate { clientLogic.Client.OnReceiveMessageEvent -= ReceivedMessageFromClient; var mainViewModel = new MainViewModel2(_login, createGameMessage.GameId, clientLogic); mainViewModel.Window.Show(); Window.Close(); }); }