Skip to content

ScrollView click sometimes throws when async-waiting for MainLoop-synched MessageBox #1999

@heinrich-ulbricht

Description

@heinrich-ulbricht

Describe the bug
After #1993 being my fault I put my MessageBox invocations inside Application.MainLoop.Invoke. But since I nevertheless want to await the message boxes I wrote the following helper function that is supposed to allow awaiting the message box:

private static async Task ShowMessageBox (bool isError, ustring title, ustring message, params ustring [] buttons)
{
	var tcs = new TaskCompletionSource<int> ();
	Application.MainLoop.Invoke (() =>
	{
		if (isError) {
			var result = MessageBox.ErrorQuery (title, message, buttons);
			tcs.SetResult (result);
		} else {
			var result = MessageBox.Query (title, message, buttons);
			tcs.SetResult (result);
		}
	});
	_ = await tcs.Task.ConfigureAwait (false);
}

That seems to work. Unless it crashes. See reproduction.

To Reproduce
Steps to reproduce the behavior:

  1. Pull/rebuild/look at the repro from heinrich-ulbricht@ba88e7b - it is the modified Reactive sample showing the changes needed to provoke the error (it adds a ScrollView and the async method from above)
  2. Launch ReactiveExample
  3. Enter values and click on "Login" - the message box appears
    image
  4. While leaving the message box open click some UI elements

This error should appear:
image

The error does not always happen. Keep closing, opening and clicking until it happens.

Am I again wrong in some assumptions here? Async contexts etc.? Or should this work? Note that without the scroll view it works fine.

Expected behavior
I expect the error not to happen.

Desktop (please complete the following information):

  • OS: Windows 11
  • Version: current dev branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions