Ejemplo n.º 1
0
        public static async Task <bool> CloseAllConnectionsAsync(this HttpConnectionManager connectionManager, CancellationToken token)
        {
            var closeTasks = new List <Task>();

            connectionManager.Walk(connection =>
            {
                closeTasks.Add(connection.StopProcessingNextRequestAsync());
            });

            var allClosedTask = Task.WhenAll(closeTasks.ToArray());

            return(await Task.WhenAny(allClosedTask, CancellationTokenAsTask(token)).ConfigureAwait(false) == allClosedTask);
        }
Ejemplo n.º 2
0
        public static async Task <bool> AbortAllConnectionsAsync(this HttpConnectionManager connectionManager)
        {
            var abortTasks        = new List <Task>();
            var canceledException = new ConnectionAbortedException(CoreStrings.ConnectionAbortedDuringServerShutdown);

            connectionManager.Walk(connection =>
            {
                abortTasks.Add(connection.AbortAsync(canceledException));
            });

            var allAbortedTask = Task.WhenAll(abortTasks.ToArray());

            return(await Task.WhenAny(allAbortedTask, Task.Delay(1000)).ConfigureAwait(false) == allAbortedTask);
        }
Ejemplo n.º 3
0
 public void OnHeartbeat(DateTimeOffset now)
 {
     _now = now;
     _connectionManager.Walk(_walkCallback);
 }