public async Task Invoke(ICommunicationContext env) { env.Yielder(_yieldName).SetResult(true); var currentContext = HttpContext.Current; var shouldContinue = await env.Resumer(_yieldName).Task; if (HttpContext.Current == null) { HttpContext.Current = currentContext; } if (shouldContinue) { await Next.Invoke(env); } }
async Task Resume <T>() { Env.Resumer(typeof(T).Name).SetResult(true); await Operation; }