예제 #1
0
            public AddedEventDispatcher(Collection <V> collection, EventQueue dispatcher, AddedEventHandler handler)
            {
                this.Collection = collection;

                this.Handler = dispatcher != null
                    ? delegate(Collection <V> .AddedEventArgs args) { dispatcher.Post(delegate() { handler(args); }); }
                    : handler;

                this.Collection.Added += this.Handler;
            }
예제 #2
0
            public void Dispose()
            {
                AddedEventHandler handler = Interlocked.Exchange(ref this.Handler, null);

                this.Collection.Added -= handler;
            }
예제 #3
0
 public IDisposable Listen(EventQueue dispatcher, AddedEventHandler handler)
 {
     // The AddedEventDispatcher constructor adds an event handler to the Added event.
     return(new AddedEventDispatcher(this, dispatcher, handler));
 }