Skip to content

Instantly share code, notes, and snippets.

View rudyhuyn's full-sized avatar
🐕

Rudy Huyn rudyhuyn

🐕
View GitHub Profile
@rudyhuyn
rudyhuyn / AsyncHelper.cs
Last active September 6, 2019 08:34
How to call an async method synchronously
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
public static class AsyncHelper
{
public static void RunSync(this Func<Task> task)
{
var oldContext = SynchronizationContext.Current;