示例#1
0
            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;
            }
示例#2
0
            public void Dispose()
            {
                RemovedEventHandler handler = Interlocked.Exchange(ref this.Handler, null);

                this.Collection.Removed -= handler;
            }
示例#3
0
 public IDisposable Listen(EventQueue dispatcher, RemovedEventHandler handler)
 {
     // The RemovedEventDispatcher constructor adds an event handler to the Removed event.
     return(new RemovedEventDispatcher(this, dispatcher, handler));
 }