I found this method in an ASP.NET application:
public void LogoutAllSessions()
{
Task.Run(async () => await _identityHttpClient.GetAsync(Uri)).Wait();
// Could this be rewritten as this:?
// _identityHttpClient.GetAsync(Uri).GetAwaiter().GetResult();
}
Is this just running a task within another task and blocking the thread while it waits for the outer task to finish?
I was told it was written like this because updating it to just use plain async/await would involve changing too many methods up the stack.
Would _identityHttpClient.GetAsync(Uri).GetAwaiter().GetResult();
do the same thing as Task.Run(async () => await _identityHttpClient.GetAsync(Uri)).Wait();
?
Would one be faster than the other?