I have the following basic WPF app, where I want the content displayed in the text box. However, when I click on the button, the UI thread seems to be blocking. I am not sure wh
This shouldn't block the UI thread, and the technique is correct.
However, just because a method is Async, and returns a Task<T>
, doesn't guarantee that the entire method (or any of it) will run asynchronously.
In the case of WebClient
, the control won't return to the caller until after the request has been completely prepared and started. With WebClient
, I believe the URI preparation, including all of the DNS lookups, can happen synchronously and is required before the asynchronous portion (the actual request) begins, which can cause a delay before the request returns.