MessageDialog ShowAsync throws accessdenied exception on second dialog

Okay I found a quick solution,

define a IAsyncOperation class varialble

IAsyncOperation<IUICommand> asyncCommand = null;

and set it to the ShowAsync method of MessageDialog

asyncCommand = msg.ShowAsync();

In the command handler for retry/try again
check if asyncCommand is not null and cancel the last operation if necessary

if(asyncCommand != null)
{
   asyncCommand.Cancel();
}

Please let me if there is a better approach to this.

Leave a Comment