private void DispatcherOnStartGame(object sender, InvitationHandshake invitationHandshake) { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed UsersListView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Guid opponentId = (_myInvitations.Any(inv => inv.InvitationGuidString == invitationHandshake.Invitation.InvitationGuidString)) ? invitationHandshake.Invitation.InvitedPlayerId : invitationHandshake.Invitation.InvitingPlayerId; try { var opponent = GetPlayerById(opponentId); if (String.IsNullOrEmpty(opponent.Name)) { opponent.Name = invitationHandshake.Invitation.InvitationGuidString; } if (_gameList.All(inv => inv.Invitation.InvitationGuidString != invitationHandshake.Invitation.InvitationGuidString)) { _gameList.Add(new InvitationListItem { Invitation = invitationHandshake.Invitation, Opponent = opponent }); InvitationsListView.ItemsSource = _gameList; } // var navigationParams = new Dictionary<Type, object>() { // {typeof (Player), opponent}, // {typeof (GameType), GameType.PlayerVsPlayer} // }; // (Window.Current.Content as Frame).Navigate(typeof(GamePage), navigationParams); } catch (NullReferenceException ex) { Debug.WriteLine("NPE caught at DispatcherOnStartGame: " + ex.Message); } }); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }
private void InvitationReceived(object sender, InvitationHandshake e) { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed UsersListView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { try { _dispatcher.AddRequest(new EventRequest { RequestType = EventRequestType.AcceptInvitation, RequestObject = e.Invitation }); } catch (NullReferenceException ex) { Debug.WriteLine("NPE caught at InvitationReceived:" + ex.Message); } }); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }