/** <summary>Unsubscribes the the IDataHandler if it is the current IDatahandler.</summary> <param name="hand">An IDataHandler that wishes to remove itself as a destination for data coming from this source.</param> */ public void Unsubscribe(IDataHandler h) { Subscriber s = new Subscriber(h, null); //We have to lock so there is no race between the read and the write lock( _sync ) { int idx = _subs.IndexOf(s); _subs = Functional.RemoveAt(_subs, idx); } }
/** <summary>Unsubscribes the the IDataHandler if it is the current IDatahandler.</summary> <param name="hand">An IDataHandler that wishes to remove itself as a destination for data coming from this source.</param> */ public virtual void Unsubscribe(IDataHandler hand) { lock(_sync) { if( _sub.Handler == hand ) { _sub = null; } else { throw new Exception(String.Format("Handler: {0}, not subscribed", hand)); } } }
/** <summary>Subscribes the out going data from this source to the specified handler.</summary> <param name="hand">Data that the subscriber wants passed to the handler on each call.</param> <param name="state">Data that the subscriber wants passed to the handler on each call.</param> */ public void Subscribe(IDataHandler h, object state) { Subscriber s = new Subscriber(h, state); //We have to lock so there is no race between the read and the write lock( _sync ) { _subs = Functional.Add(_subs, s); } }
/** <summary>Subscribes the out going data from this source to the specified handler.</summary> <param name="hand">Data that the subscriber wants passed to the handler on each call.</param> <param name="state">Data that the subscriber wants passed to the handler on each call.</param> */ public virtual void Subscribe(IDataHandler hand, object state) { lock(_sync) { _sub = new Subscriber(hand, state); } }