XF-Material-Library icon indicating copy to clipboard operation
XF-Material-Library copied to clipboard

await MaterialDialog.Instance.AlertAsync not waiting

Open zillemarco opened this issue 3 years ago • 0 comments

🐛 Bug Report

A call to await MaterialDialog.Instance.AlertAsync does not wait unitl the dialog's dismiss before continuing.

Doing some tests, calling var msgResult = await MaterialDialog.Instance.ConfirmAsync actually waits so I looked at the code to see what the differences are. I think the problem is due to the way the dialog is shown on the AlertAsync: in AlertAsync the task returned is the one from await dialog.ShowAsync https://github.com/Baseflow/XF-Material-Library/blob/589fcf485576d2717e6090789aeb17ed75e2a140/XF.Material/UI/Dialogs/MaterialAlertDialog.xaml.cs#L43

On ConfirmAsync the returned task is the one from InputTaskCompletionSource which is fired only after a button press https://github.com/Baseflow/XF-Material-Library/blob/589fcf485576d2717e6090789aeb17ed75e2a140/XF.Material/UI/Dialogs/MaterialAlertDialog.xaml.cs#L61

For now a workaround is just to call ConfirmAsync instead of AlertAsync and setting dismissiveText to null, with this we have basically the same funcionality of AlertAsync.

Configuration

Version: 1.7.5

Platform:

  • [ ] :iphone: iOS
  • [x] :robot: Android
  • [ ] :checkered_flag: WPF
  • [ ] :earth_americas: UWP
  • [ ] :apple: MacOS
  • [ ] :tv: tvOS
  • [ ] :monkey: Xamarin.Forms

zillemarco avatar Nov 03 '20 08:11 zillemarco