private void observerRemoved(IServiceObserverPrx observer, System.Exception ex) { if (_traceServiceObserver >= 1) { // // CommunicatorDestroyedException may occur during shutdown. The observer notification has // been sent, but the communicator was destroyed before the reply was received. We do not // log a message for this exception. // if (!(ex is CommunicatorDestroyedException)) { _logger.trace("IceBox.ServiceObserver", $"Removed service observer {observer}\nafter catching {ex}"); } } }
observerCompleted(IServiceObserverPrx observer, Task t) { try { t.Wait(); } catch (AggregateException ae) { lock (this) { if (_observers.Remove(observer)) { observerRemoved(observer, ae.InnerException); } } } }
public void AddObserver(IServiceObserverPrx observer, Ice.Current current) { List <string> activeServices = new List <string>(); // // Null observers and duplicate registrations are ignored // lock (this) { if (observer != null) { try { _observers.Add(observer, true); } catch (ArgumentException) { return; } if (_traceServiceObserver >= 1) { _logger.trace("IceBox.ServiceObserver", $"Added service observer {observer}"); } foreach (ServiceInfo info in _services) { if (info.Status == ServiceStatus.Started) { activeServices.Add(info.Name); } } } } if (activeServices.Count > 0) { observer !.ServicesStartedAsync(activeServices.ToArray()).ContinueWith((t) => observerCompleted(observer, t), TaskScheduler.Current); } }