private async Task SubscribeToAll() { RedisLog.Subscribing(_logger, _channels.All); var channel = await _bus.SubscribeAsync(_channels.All); channel.OnMessage(async channelMessage => { try { RedisLog.ReceivedFromChannel(_logger, _channels.All); var invocation = _protocol.ReadInvocation((byte[])channelMessage.Message); var tasks = new List <Task>(_connections.Count); foreach (var connection in _connections) { if (invocation.ExcludedConnectionIds == null || !invocation.ExcludedConnectionIds.Contains(connection.ConnectionId)) { tasks.Add(connection.WriteAsync(invocation.Message, CancellationToken.None)); } } await Task.WhenAll(tasks); } catch (Exception ex) { RedisLog.FailedWritingMessage(_logger, ex); } }); }