You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: