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
Is it possible to Query for already enabled Events, like
if (!LayoutManager.Current.LayoutSwitched.Has(OnLayoutSwitched))
LayoutManager.Current.LayoutSwitched += ...
Thanks for any help.
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.