I would like to prevent changing the current page by pressing Back button or any navigation events while awaiting not finished. Because then exception happens, its should shown in the same page, on the other case it would be difficult to understand what action generate this exception
private async void AppBarButton_Click(object sender, RoutedEventArgs e)
{
MessageDialog dialog = null;
try
{
progressRing.IsActive = true;
this.IsEnabled = false;
commandBar1.IsEnabled = false;
await GlobalVars.API.Call(CC.ChangeDate, date);
var notify = new MessageDialog("Done");
await notify.ShowAsync();
}
catch (Exception ex)
{
dialog = new MessageDialog(ex.Message);
}
finally
{
progressRing.IsActive = false;
this.IsEnabled = true;
commandBar1.IsEnabled = true;
}
if (dialog != null) await dialog.ShowAsync(); // must be shown in the same page
}