public RemovedEventDispatcher(Collection <V> collection, EventQueue dispatcher, RemovedEventHandler handler) { this.Collection = collection; this.Handler = dispatcher != null ? delegate(Collection <V> .RemovedEventArgs args) { dispatcher.Post(delegate() { handler(args); }); } : handler; this.Collection.Removed += this.Handler; }
public void Dispose() { RemovedEventHandler handler = Interlocked.Exchange(ref this.Handler, null); this.Collection.Removed -= handler; }
public IDisposable Listen(EventQueue dispatcher, RemovedEventHandler handler) { // The RemovedEventDispatcher constructor adds an event handler to the Removed event. return(new RemovedEventDispatcher(this, dispatcher, handler)); }