using System; using System.Threading.Tasks; public class Class1 { protected void InvokeAction (Action action) { action (); } public void Bar() { } async Task Test () { Task.Run(async () => { var implementor = ServiceLocator.GetImplementor (); string message = null; bool result = await implementor.Foo ((s) => message = s); InvokeAction (() => Bar ()); }).Wait (); } interface IInterface1 { Task Foo(Action action); } class CIInterface1 : IInterface1 { public Task Foo (Action action) { action ("msg"); return Task.FromResult (false); } } static class ServiceLocator { public static TService GetImplementor() where TService : class { return (TService) (object) new CIInterface1 (); } } public static void Main () { new Class1 ().Test ().Wait (); } }