Task.Run to call asynchronous method from synchronous method in C#

Viewed 215

I have seen examples like the followings to call asynchronous method from synchronous method

Task.Run(async () => await MyAsyncMethod()).ConfigureAwait(false).GetAwaiter().GetResult();

and

Task.Run(() => MyAsyncMethod()).GetAwaiter().GetResult();

I know the ConfigreAwait is needed only for the await call to synchronize back to its context. My question is why and when to use the async and await in the Task.Run (1st sample above).

Just find out the similar question was asked at Aync/Await action within Task.Run()

0 Answers
Related