private Task OpenServiceReplicaListeners() { var serviceReplicaListeners = _serviceInstance.InvokeCreateServiceReplicaListeners(); OpenListeners = serviceReplicaListeners .Where(rl => ReplicaRole == ReplicaRole.ActiveSecondary && rl.ListenOnSecondary || ReplicaRole == ReplicaRole.Primary) .Select(rl => rl.CreateCommunicationListener(_context)) .ToList(); return(Task.WhenAll(OpenListeners.Select(l => l.OpenAsync(OpenCancellation.Token)))); }
private Task CloseServiceReplicaListeners() => Task.WhenAll(OpenListeners.Select(l => l.CloseAsync(CloseCancellation.Token)));