public override async Task<bool> Shutdown()
{
try
{
var tasks = new List<Task>();
foreach (var channel in ConnectionGroup)
{
tasks.Add(channel.CloseAsync());
}
var all = Task.WhenAll(tasks);
await all;
var server = ServerChannel?.CloseAsync() ?? TaskEx.Completed;
await server;
return all.IsCompleted && server.IsCompleted;
}
finally
{
// free all of the connection objects we were holding onto
ConnectionGroup.Clear();
#pragma warning disable 4014 // shutting down the worker groups can take up to 10 seconds each. Let that happen asnychronously.
_clientEventLoopGroup.ShutdownGracefullyAsync();
_serverEventLoopGroup.ShutdownGracefullyAsync();
#pragma warning restore 4014
}
}