Example #1
0
        private async void ConnectButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            try
            {
                ConnectButton.IsEnabled = false;

                // Try to get the service
                if (service == null)
                {
                    service = await MessageProtocolClient.GetServiceAsync(deviceId);
                }

                // Now try to get the Wi-Fi network status of the device.
                messageProtocolClient.WifiStatusRequestReceived += WifiStatusRequest_RequestReceived;
                await messageProtocolClient.ListenForWifiStatusAsync(service);

                // Update button.
                ConnectButton.Content   = "Refresh";
                ConnectButton.IsEnabled = true;
            }
            catch (Exception ex)
            {
                MessageDialog exceptionAlert = new MessageDialog(ex.Message, "Alert");
                exceptionAlert.Commands.Add(new UICommand("OK"));
                await exceptionAlert.ShowAsync();

                ConnectButton.IsEnabled = true;
                return;
            }
        }