コード例 #1
0
        /// <summary>
        /// Subscribes the specified observer.
        /// </summary>
        /// <param name="observer">The observer.</param>
        /// <returns>An IDisposable.</returns>
        public IDisposable Subscribe(IObserver <T> observer)
        {
            if (_theObserver != null)
            {
                throw new InvalidOperationException(
                          "There should be only one observer attached to the Firehose Observable");
            }

            var messageTransportWaitCallBackId = Guid.Empty;

            try
            {
                _theObserver = observer;
                var topicObserver = new TopicObserver(_topic, observer);
                topicObserver.Start();

                return
                    (Disposable.Create(
                         () => topicObserver.Stop()));
            }
            catch (Exception ex)
            {
                Tracer.TraceSource.TraceEvent(
                    TraceEventType.Error,
                    0,
                    "Fire hose observable - topic:{0}, waitCallbackId:{1}, unable to subscribe to fire hose observable - {2}",
                    _topic,
                    messageTransportWaitCallBackId,
                    ex);

                throw;
            }
        }
コード例 #2
0
 protected override void OnDispose()
 {
     base.OnDispose();
     _topicObserver.Stop();
     Params.Subscriptions[_subscriptionIndex] = new Subscription(Params.Subscriptions[_subscriptionIndex].Subscribe, _scheduler.Now.Ticks);
 }