private static async Task RunAsync(this IGrpcHost host, CancellationToken token = default(CancellationToken)) { if (token.CanBeCanceled) { await host.RunAsync(token, null); return; } var done = new ManualResetEventSlim(false); using (var cts = new CancellationTokenSource()) { AttachCtrlcSigtermShutdown(cts, done, "Application is shutting down..."); await host.RunAsync(cts.Token, "Application started. Press Ctrl+C to shut down."); done.Set(); } }
public static void Run(this IGrpcHost host) { host.RunAsync().GetAwaiter().GetResult(); }