Skip to content
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.

Commit

Permalink
Show error message when WiFi scanning is aborted
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoshibata committed Feb 14, 2017
1 parent 370dfc7 commit 8fe7809
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -191,7 +192,15 @@ private async Task<bool> UpdateInfo()
return false;
}

await adapter.ScanAsync();
try
{
await adapter.ScanAsync();
}
catch (Exception e)
{
Debug.WriteLine(String.Format("Error scanning {0}: 0x{1:X}: {2}", adapter.NetworkAdapter.NetworkAdapterId, e.HResult, e.Message));
continue;
}

if (adapter.NetworkReport == null)
{
Expand Down
10 changes: 9 additions & 1 deletion WiFiConnector/CS/WiFiConnect_Scenario.xaml.cs
Expand Up @@ -70,7 +70,15 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)

private async void Button_Click(object sender, RoutedEventArgs e)
{
await firstAdapter.ScanAsync();
try
{
await firstAdapter.ScanAsync();
}
catch (Exception err)
{
rootPage.NotifyUser(String.Format("Error scanning WiFi adapter: 0x{0:X}: {1}", err.HResult, err.Message), NotifyType.ErrorMessage);
return;
}
ConnectionBar.Visibility = Visibility.Collapsed;
DisplayNetworkReport(firstAdapter.NetworkReport);
}
Expand Down

0 comments on commit 8fe7809

Please sign in to comment.