public async void AddSessionRequest(WiFiDirectServiceSessionRequest request, AdvertisementWrapper advertiser)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         lock (thisLock)
         {
             SessionRequestWrapper sessionRequest = new SessionRequestWrapper(request, advertiser);
             SessionRequests.Items.Add(sessionRequest);
         }
     });
 }
 private void Decline_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     if (SessionRequests.Items.Count > 0)
     {
         int requestIndex = SessionRequests.SelectedIndex;
         if (requestIndex >= 0)
         {
             SessionRequestWrapper request = SessionRequests.Items[requestIndex] as SessionRequestWrapper;
             request.Advertisement.DeclineSessionRequest(request.Id);
         }
     }
 }
            protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                lock (thisLock)
                {
                    rootPage = MainPage.Current;

                    MainUI.Visibility        = Windows.UI.Xaml.Visibility.Collapsed;
                    PlaceholderUI.Visibility = Windows.UI.Xaml.Visibility.Visible;

                    // Fill in all existing data
                    if (WiFiDirectServiceManager.Instance.Advertisers.Count > 0)
                    {
                        // Session Requests
                        SessionRequests.Items.Clear();

                        // Advertisers
                        Advertisements.Items.Clear();
                        foreach (var advertiser in WiFiDirectServiceManager.Instance.Advertisers)
                        {
                            Advertisements.Items.Add(advertiser);

                            foreach (var request in advertiser.SessionRequestList)
                            {
                                SessionRequestWrapper sessionRequest = new SessionRequestWrapper(request, advertiser);
                                SessionRequests.Items.Add(sessionRequest);
                            }
                        }

                        // Connected Sessions
                        ConnectedSessions.Items.Clear();
                        foreach (var session in WiFiDirectServiceManager.Instance.ConnectedSessionList)
                        {
                            ConnectedSessions.Items.Add(session);
                        }

                        MainUI.Visibility        = Windows.UI.Xaml.Visibility.Visible;
                        PlaceholderUI.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    }
                }
                WiFiDirectServiceManager.Instance.Scenario2 = this;
            }
            protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                lock (thisLock)
                {
                    rootPage = MainPage.Current;
                    
                    MainUI.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    PlaceholderUI.Visibility = Windows.UI.Xaml.Visibility.Visible;

                    // Fill in all existing data
                    if (WiFiDirectServiceManager.Instance.Advertisers.Count > 0)
                    {
                        // Session Requests
                        SessionRequests.Items.Clear();

                        // Advertisers
                        Advertisements.Items.Clear();
                        foreach (var advertiser in WiFiDirectServiceManager.Instance.Advertisers)
                        {
                            Advertisements.Items.Add(advertiser);

                            foreach (var request in advertiser.SessionRequestList)
                            {
                                SessionRequestWrapper sessionRequest = new SessionRequestWrapper(request, advertiser);
                                SessionRequests.Items.Add(sessionRequest);
                            }
                        }
                        
                        // Connected Sessions
                        ConnectedSessions.Items.Clear();
                        foreach (var session in WiFiDirectServiceManager.Instance.ConnectedSessionList)
                        {
                            ConnectedSessions.Items.Add(session);
                        }

                        MainUI.Visibility = Windows.UI.Xaml.Visibility.Visible;
                        PlaceholderUI.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    }
                }
                WiFiDirectServiceManager.Instance.Scenario2 = this;
            }
 public async void AddSessionRequest(WiFiDirectServiceSessionRequest request, AdvertisementWrapper advertiser)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         lock (thisLock)
         {
             SessionRequestWrapper sessionRequest = new SessionRequestWrapper(request, advertiser);
             SessionRequests.Items.Add(sessionRequest);
         }
     });
 }