I have to use a third-party library in a ASP.NET web forms app.
The third-party method I have to use is an async one.
Since I have to call it in a page click event handler, I have 2 options:
- Declare every page that has to use this method as <%@ Page Async="true" ... %>
- Invoke the method synchronously.
FIRST QUESTION
Does it make sense to declare all the website pages async only for this method (potentially can be invoked on every page)?
SECOND QUESTION
The second question is about invoking the async method synchronously.
Having to invoke the following method
async Task<bool> MyMethodAsync()
{
...
}
Which is the difference between the next 3 invocations?
Task.Run(async () => await MyMethodAsync()).GetAwaiter().GetResult();
Task.Run(() => MyMethodAsync()).GetAwaiter().GetResult();
MyMethodAsync().GetAwaiter().GetResult();
I cannot see any difference during execution…
Thanks!