I'm using Microsoft's AsyncHelper
(source) to call an async method from a synchronous context. This works just fine:
Result r = AsyncHelper.RunSync(async () => await SomeClass.SomeMethodAsync());
However, if I extract the Task and then try to run this extracted task synchronously instead, I encounter a deadlock.:
Task<Result> t = SomeClass.SomeMethodAsync();
Result r = AsyncHelper.RunSync(async () => await t);
Why does this happen, and what can be done to make this run?