Task Process(IHttpContext context) { return(Task.Run(() => { try { Console.WriteLine("Start"); foreach (var item in this.funList) { item(context); } var stream = context.Get <Stream>(HttpBuilder.ResponseBody); var response = new HttpResponse(stream) { Content = "test" }; response.WriteResponse(); context.Dispose(); Console.WriteLine("End"); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { context.Dispose(); } })); }