예제 #1
0
        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);
            }
        }
예제 #2
0
 Task RunNonBlocking(Settings settings)
 {
     using (var service = new HostService {
         Settings = settings
     })
     {
         service.Run(false);
     }
     return(Task.FromResult(0));
 }