Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - frits432

Pages: [1]
Events / Query for EventHandlers
« on: November 16, 2011, 09:29:53 AM »
While experimenting with events i noticed that you can add the same handler more than once but found no easy way to prevent this, other than define static variables remembering events already enabled.
Such as
Code: [Select]
public static class Class1
        private bool eventsEnabled;
         public void EnableEvents()
             if (!eventsEnabled)
                 LayoutManager.Current.LayoutSwitched += new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(OnLayoutSwitched);
                 eventsEnabled = true;

Is it possible to Query for already enabled Events, like

if (!LayoutManager.Current.LayoutSwitched.Has(OnLayoutSwitched))
LayoutManager.Current.LayoutSwitched += ...

Thanks for any help.

Pages: [1]