I have the following methods:
public override bool SyncNavigationMethod()
{
AsyncShowDialog().Wait();
return true;
}
public Task AsyncShowDialog()
{
//code to show dialog and process user input from the dialog.
}
what happens is that the app goes into a deadlock when SyncNavigationMethod is called.
My guess is that it runs on the MainThread, who is waiting for AsyncShowDialog to complete, and the dialog that is shown cannot call it's callback because it's the MainThread that calls it. And so, the main thread waits to itself and it's a deadlock.
More information:
- runtime - UWP.
- device: phone (as described above) desktop (the app freezes before the dialog is shown).
- I have tried to use .Wait() \ .Result on AsyncShowDialog.
- I have tried to use a ManualResetEvent after calling the AsyncShowDialog to block the code from progressing while AsyncShowDialog is running.
Am I right suspecting a deadLock?
How can I call AsyncShowDialog from SyncNavigationMethod without this deadlock?
Thanks.