private static async Task HttpServer() { CoopScheduler.AddTask(async() => { while (true) { await Task.Delay(1000); Console.WriteLine("waiting"); } }); HttpListener l = new HttpListener(); l.Prefixes.Add("http://+:8080/"); l.Start(); while (true) { var ctx = await l.GetContextAsync(); CoopScheduler.AddTask(() => HandleRequest(ctx)); } }
public static void StartServerAt(string port) { CoopScheduler.AddTask(HttpServer); CoopScheduler.StartScheduler(); }
static void Main(string[] args) { CoopScheduler.AddTask(httpServer); CoopScheduler.StartScheduler(); }