private IAsyncOperation _Task = null;
private ContentDialog _message = null;
_message = new ContentDialog()
To prevent the dialog from closing handle its Closing event and set Cancel to true in its ContentDialogClosingEventArgs argument.
When initializing the dialog:
myContentDialog.Closing += ContentDialog_Closing;
Event handler:
void ContentDialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
{
if (doNotClose)
{
args.Cancel = true;
}
}