async Task RunAndWait(Settings settings) { using (var service = new HostService { Settings = settings }) { var tcs = new TaskCompletionSource <bool>(); Action done = () => { service.OnStopping = () => { }; tcs.SetResult(true); }; service.OnStopping = done; OnConsoleCancel.Run(done); service.Run(true); Console.WriteLine("Press Ctrl+C to exit"); await tcs.Task.ConfigureAwait(false); } }
Task RunNonBlocking(Settings settings) { using (var service = new HostService { Settings = settings }) { service.Run(false); } return(Task.FromResult(0)); }