Пример #1
0
 public IAsyncOperation <OnboardingConnectResult> ConnectAsync(AllJoynMessageInfo info)
 {
     return(Task.Run(() =>
     {
         // Find the network with the specified Ssid
         foreach (var network in _wlanAdapter.NetworkReport.AvailableNetworks)
         {
             if (network.Ssid == _personalApSsid)
             {
                 _softAccessPoint?.Stop();
                 this.ConnectToNetwork(network);
             }
         }
         return OnboardingConnectResult.CreateSuccessResult();
     }).AsAsyncOperation());
 }
        // Method to handle calls to the Connect method.
        IAsyncOperation <OnboardingConnectResult> IOnboardingService.ConnectAsync(AllJoynMessageInfo info)
        {
            Task <OnboardingConnectResult> task = new Task <OnboardingConnectResult>(() =>
            {
                EventHandler handler = ConnectRequestRecieved;
                if (handler != null)
                {
                    handler(new object(), new EventArgs());
                }

                return(OnboardingConnectResult.CreateSuccessResult());
            });

            task.Start();
            return(task.AsAsyncOperation());
        }
Пример #3
0
 public IAsyncOperation <OnboardingConnectResult> ConnectAsync(AllJoynMessageInfo info)
 {
     return(Task.Run(async() =>
     {
         // Find the network with the specified Ssid
         var adapter = await WiFiAdapter.FromIdAsync(_wlanAdapterId);
         foreach (var network in adapter.NetworkReport.AvailableNetworks)
         {
             if (network.Ssid == _personalApSsid)
             {
                 var result = await this.ConnectToNetwork(adapter, network);
                 if (result == WiFiConnectionStatus.Success)
                 {
                     _softAccessPoint?.Stop();
                     return OnboardingConnectResult.CreateSuccessResult();
                 }
                 break;
             }
         }
         return OnboardingConnectResult.CreateFailureResult(1);
     }).AsAsyncOperation());
 }