コード例 #1
0
            // 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);
            }
コード例 #2
0
 public void RegisterTelemetryListener(ITelemetryListener telemetryListener)
 {
     TelemetryListeners.Add(telemetryListener);
 }
コード例 #3
0
ファイル: TelemetryHub.cs プロジェクト: lodejard/Notification
 // 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;
 }