C# Run async task in sync task (and wait for it)

Date: 2019-02-26
public static void RunSync(Func<Task> fn) => Task.Run(fn).ConfigureAwait(false).GetAwaiter().GetResult();
public static T RunSync<T>(Func<Task<T>> fn) => Task.Run(fn).ConfigureAwait(false).GetAwaiter().GetResult();

// an async main:
static void Main(string[] args)
{
     var result = RunSync(() => MainAsync());
     Console.ReadKey();
}
19210cookie-checkC# Run async task in sync task (and wait for it)