Event handlers will be called synchronously and will not wait (wait) until the event handler completes, but waits until the event handler returns.
If the previous sentence was confusing enough, I will try to explain it clearly. Asynchronous methods terminate when all waiting points are executed and the end of the method body is completed or any return statement is executed (ignoring an exception). But the asynchronous method returns as soon as you press the first wait statement for Task , which is not yet complete. In other words, an asynchronous method can return several times, but can only end once.
So now we know when the asynchronous method completes and returns. The event handler will assume that your method completed as soon as it returns not when it actually completed.
As soon as your event handler reaches the first await statement, it will return; if more methods are added to the same event handler, it will continue to execute without waiting for the asynchronous method to complete.
Yes, do stuff will be executed in the user interface thread if the user interface thread fires an event, and yes do more stuff will also be executed in the user interface thread until longRunning().ConfigureAwait(false) .
source share