public Task<ResultParameters> Invoke(CallParameters call) { var request = new Request(call); var response = new Response() { ContentType = "text/html", }; var wilson = "left - right\r\n123456789012\r\nhello world!\r\n"; response.StartAsync().Then(resp1 => { var href = "?flip=left"; if (request.Query["flip"] == "left") { wilson = wilson.Split(new[] {System.Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries).Select(line => new string(line.Reverse().ToArray())).Aggregate("", (agg, line) => agg + line + System.Environment.NewLine); href = "?flip=right"; } return TimerLoop(350, () => resp1.Write("<title>Hutchtastic</title>"), () => resp1.Write("<pre>"), () => resp1.Write(wilson), () => resp1.Write("</pre>"), () => { if (request.Query["flip"] == "crash") { throw new ApplicationException("Wilson crashed!"); } }, () => resp1.Write("<p><a href='" + href + "'>flip!</a></p>"), () => resp1.Write("<p><a href='?flip=crash'>crash!</a></p>"), () => resp1.End()); }).Catch(errorInfo => { response.Error(errorInfo.Exception); return errorInfo.Handled(); }); return response.ResultTask; }