Quantcast
Channel: Autodesk AutoCAD forums
Viewing all articles
Browse latest Browse all 14319

Avoiding duplicate Eventhandlers

$
0
0

In order to avoid duplicate eventhandlers, I did like the following...

 

Document doc = Application.DocumentManager.MdiActiveDocument;
try { doc.BeginDocumentClose -= new DocumentBeginCloseEventHandler(MyEventHandler); }
catch { // Do nothing }
doc.BeginDocumentClose += new DocumentBeginCloseEventHandler(MyEventHandler);

 

The above worked greatly with AutoCAD 2007.

But yesterday I migrated my code into AutoCAD 2010 (with Object ARX 2010).

 

Unfortunately, it seems like AutoCAD 2010 catches before my code catches it.... (Though I am not sure if this is even make sense)

 

The evidence...

 

error.PNG

 

If I ignore this message, everything works great as it was meant to be...

 

I am just wondering if I could disable(?) this. Or if there is any other effective work around....

Well, I guess I could just have a global boolean value that checks the status of event attachment.

But would this be the only way?


Viewing all articles
Browse latest Browse all 14319

Latest Images

Trending Articles



Latest Images