private async void AskForGame(string userName) { await Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { if (userName != App.CurrentUser.Username) { _AnswerForGameDialog.Content = $"\"{userName}\" want to play with you Backgammon"; _AnswerForGameDialog.PrimaryButtonText = "Accept"; _AnswerForGameDialog.SecondaryButtonText = "Decline"; timerAskForGame.Interval = new TimeSpan(TIME_FOR_TIMER); timerAskForGame.Tick += timerAskForGame_Tick; timerAskForGame.Start(); ContentDialogResult result = await _AnswerForGameDialog.ShowAsync(); PushAskForGameHandler.Dispose(); if (result == ContentDialogResult.Primary) { timerAskForGame.Stop(); await myApp.MyHubProxy.Invoke("AnswerToGameRequest", App.CurrentUser.Username, userName, true); } if (result == ContentDialogResult.Secondary) { timerAskForGame.Stop(); await myApp.MyHubProxy.Invoke("AnswerToGameRequest", App.CurrentUser.Username, userName, false); } } }); }
protected override void OnNavigatedFrom(NavigationEventArgs e) { base.OnNavigatedFrom(e); PushConnectMessageHandler.Dispose(); PushDisconnectMessageHandler.Dispose(); receiveMessageHandler.Dispose(); PushAskForGameHandler.Dispose(); SaveMessagesHandler.Dispose(); AnswerToGameHandler.Dispose(); GameCacnceledHandler.Dispose(); }