简体   繁体   中英

DisplayPromptAsync hangs on Uno Platform for Xamarin Forms WASM

I have an application that works on UWP. It contains this piece of code:

        private async void Button_Clicked(object sender, EventArgs e)
        {
            var response1 = await App.Current.MainPage.DisplayPromptAsync("", "message1", "OK", "Cancel", "");
            if (string.IsNullOrEmpty(response1)) return;
            var response2 = await App.Current.MainPage.DisplayPromptAsync("", "message2", "OK", "Cancel", "");
            if (string.IsNullOrEmpty(response2)) return;
        }

The code works properly on UWP. However, on Uno for WASM, only the first response is captured properly. The second response hangs the web application completely.

Looking at the console, it might be a threading error, AFTER I press the OK button for the first prompt:

  Failed to raise 'PointerReleasedEvent': System.InvalidOperationException
dotnet.js:1         at System.Threading.Tasks.TaskCompletionSource`1[TResult].SetResult (TResult result) [0x00009] in /__w/1/s/mono/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/TaskCompletionSource.cs:298 
dotnet.js:1         at Windows.UI.Xaml.Controls.ContentDialog.<ProcessPrimaryButton>g__Complete|52_0 (Windows.UI.Xaml.Controls.ContentDialogButtonClickEventArgs a) [0x00022] in C:\a\1\s\src\Uno.UI\UI\Xaml\Controls\ContentDialog\ContentDialog.cs:355 
dotnet.js:1         at Windows.UI.Xaml.Controls.ContentDialog.ProcessPrimaryButton () [0x0002d] in C:\a\1\s\src\Uno.UI\UI\Xaml\Controls\ContentDialog\ContentDialog.cs:365 
dotnet.js:1         at Windows.UI.Xaml.Controls.ContentDialog.OnPrimaryButtonClicked (System.Object sender, Windows.UI.Xaml.RoutedEventArgs e) [0x00000] in C:\a\1\s\src\Uno.UI\UI\Xaml\Controls\ContentDialog\ContentDialog.cs:291 
dotnet.js:1         at (wrapper delegate-invoke) <Module>.invoke_void_object_RoutedEventArgs(object,Windows.UI.Xaml.RoutedEventArgs)
dotnet.js:1         at Windows.UI.Xaml.Controls.Primitives.ButtonBase.OnClick (Windows.UI.Xaml.Input.PointerRoutedEventArgs args) [0x00000] in C:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Primitives\ButtonBase\ButtonBase.cs:304 
dotnet.js:1         at Windows.UI.Xaml.Controls.Primitives.ButtonBase.RaiseClick (Windows.UI.Xaml.Input.PointerRoutedEventArgs args) [0x00000] in C:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Primitives\ButtonBase\ButtonBase.cs:294 
dotnet.js:1         at Windows.UI.Xaml.Controls.Primitives.ButtonBase.OnPointerReleased (Windows.UI.Xaml.Input.PointerRoutedEventArgs args) [0x00065] in C:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Primitives\ButtonBase\ButtonBase.cs:266 
dotnet.js:1         at Windows.UI.Xaml.Controls.Control+<>c.<.cctor>b__346_11 (System.Object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs args) [0x00000] in C:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Control\Control.cs:865 
dotnet.js:1         at Windows.UI.Xaml.UIElement.InvokeHandler (System.Object handler, Windows.UI.Xaml.RoutedEventArgs args) [0x000e7] in C:\a\1\s\src\Uno.UI\UI\Xaml\UIElement.RoutedEvents.cs:826 
dotnet.js:1         at Windows.UI.Xaml.UIElement.RaiseEvent (Windows.UI.Xaml.RoutedEvent routedEvent, Windows.UI.Xaml.RoutedEventArgs args, Windows.UI.Xaml.UIElement+BubblingContext ctx) [0x0007f] in C:\a\1\s\src\Uno.UI\UI\Xaml\UIElement.RoutedEvents.cs:613 
dotnet.js:1         at Windows.UI.Xaml.UIElement.RaisePointerEvent (Windows.UI.Xaml.RoutedEvent evt, Windows.UI.Xaml.Input.PointerRoutedEventArgs args) [0x0000d] in C:\a\1\s\src\Uno.UI\UI\Xaml\UIElement.Pointers.cs:933 

So what am I doing wrong here? How to properly display two consecutive prompts on an event to make in run on Uno?

This is/was a bug in the Uno Platform.

If anyone gets this problem again, just update the Uno.UI package to the latest version (3.8.0 or newer).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM