// Subscription implementation /// <summary> /// Add a subscriber, Dispose the returned value to unsubscribe. Every /// subscribers will have their ShouldNotify and Notify methods called /// whenever a producer is needs to cause a notification. /// </summary> IDisposable ITelemetryDispatcher.Subscribe(ITelemetryListener subscriber) { Subscription newSubscription = new Subscription() { Subscriber = subscriber, Owner = this, Next = m_subscriptions }; while (Interlocked.CompareExchange(ref m_subscriptions, newSubscription, newSubscription.Next) != newSubscription.Next) { newSubscription.Next = m_subscriptions; } return(newSubscription); }
public void RegisterTelemetryListener(ITelemetryListener telemetryListener) { TelemetryListeners.Add(telemetryListener); }
// Subscription implementation /// <summary> /// Add a subscriber, Dispose the returned value to unsubscribe. Every /// subscribers will have their ShouldNotify and Notify methods called /// whenever a producer is needs to cause a notification. /// </summary> IDisposable ITelemetryDispatcher.Subscribe(ITelemetryListener subscriber) { Subscription newSubscription = new Subscription() { Subscriber = subscriber, Owner = this, Next = m_subscriptions }; while (Interlocked.CompareExchange(ref m_subscriptions, newSubscription, newSubscription.Next) != newSubscription.Next) newSubscription.Next = m_subscriptions; return newSubscription; }