public static void Send(this SynchronizationContext ctx, Func <Task> func) { if (ctx == SynchronizationContext.Current) { throw new InvalidOperationException("Cannot call a synchronous Send() when the argument is an asynchronous function and the synchronization context is the currently active one."); } SynchronousSendCallback?.Invoke(); var t = ctx.SendAsync(func); try { t.Wait(); } catch (AggregateException ex) when(ex.InnerException != null) { if (ex.InnerException != null) { throw ex.InnerException; } } }