In Xamarin.Forms Device.BeginInvokeOnMainThread() doesn’t show message box from notification callback *only* in Release config on physical device

Solution 1:

Here's an answer that will work, but as @JamesMallon has mentioned, don't use it:

Device.BeginInvokeOnMainThread(ShowAlertAndWaitForUser(currentFabricCount).Result);

Your issue is very common in situations where the code is not run in the Main/UI thread. It seems that you begin the invoke on the main thread but the UI thread doesn't actually read the line, and another thread instead is performing the actions you require. And that's also why it works some times and doesn't work during other times.

So instead of performing the whole ShowAlertAndWaitForUser() on the UI thread, try to instead run only the DisplayAlert function on that thread.