Exemple #1
0
        private static async Task <BoolResult> ShutdownWithTimeoutAsync(Context context, IStartupShutdownSlim server, TimeSpan timeout)
        {
            var shutdownTask = server.ShutdownAsync(context);

            if (await Task.WhenAny(shutdownTask, Task.Delay(timeout)) != shutdownTask)
            {
                return(new BoolResult($"Server shutdown didn't finished after '{timeout}'."));
            }

            // shutdownTask is done already. Just getting the result out of it.
            return(await shutdownTask);
        }
#pragma warning disable AsyncFixer01 // Unnecessary async/await usage
            public async ValueTask DisposeAsync()
            {
                await _component.ShutdownAsync(_context).ThrowIfFailureAsync();
            }