Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XamlPlatformProvider.OnUIThreadAsync bug with Func<Task> #599

Closed
ArsenijK opened this issue Apr 11, 2019 · 1 comment
Closed

XamlPlatformProvider.OnUIThreadAsync bug with Func<Task> #599

ArsenijK opened this issue Apr 11, 2019 · 1 comment

Comments

@ArsenijK
Copy link

I see you already smartly decided, that if a user wants to call OnUIThreadAsync, then, obviously, he wants to get the Task which he returned from his Func. So we want the Task, which OnUIThreadAsync returns to complete, only when user's returned Task completes. But this is not the case. If you test it (give your OnUIThreadAsync(() => Task.Delay(10000) and await it), you'll see that it doesn't work. It's because dispatcher.InvokeAsync(action).Task returns Task and you return only the outer one, but do not wait on the inner one.
Working fix would be to make your OnUIThreadAsync actually async and await both tasks:
await await dispatcher.InvokeAsync(action).Task

nigel-sampson pushed a commit that referenced this issue Apr 14, 2019
@nigel-sampson
Copy link
Contributor

Thanks for the catch, intellisense caught me out there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants