예제 #1
0
        public static async Task <bool> CloseAllConnectionsAsync(this FrameConnectionManager connectionManager, CancellationToken token)
        {
            var closeTasks = new List <Task>();

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

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

            return(await Task.WhenAny(allClosedTask, CancellationTokenAsTask(token)).ConfigureAwait(false) == allClosedTask);
        }
예제 #2
0
        public static async Task <bool> AbortAllConnectionsAsync(this FrameConnectionManager connectionManager)
        {
            var abortTasks        = new List <Task>();
            var canceledException = new ConnectionAbortedException();

            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);
        }
 public FrameHeartbeatManager(FrameConnectionManager connectionManager)
 {
     _connectionManager = connectionManager;
     _walkCallback = WalkCallback;
 }