It is important to remember that events simply provide information on the state or activities taking place within AutoCAD. Although event handlers can be written to respond to those events, AutoCAD might be in the middle of an operation when the event handler is triggered. Event handlers, therefore, have some restrictions on what they can do if they are to provide safe operations in conjunction with AutoCAD and its database.
When writing event handlers, do not rely on the sequence of events to happen in the exact order you think they occur. For example, if you issue an OPEN command, the events CommandWillStart, DocumentCreateStarted, DocumentCreated, and CommandEnded will all be triggered. However, they may not occur in that exact order each and everytime. The only thing you can rely on is that a most events occur in pairs, a beginning and ending event.
If you delete object1 and then object2, do not rely on the fact that you will receive the ObjectErased event for object1 and then for object2. You may receive the ObjectErased event for object2 first.
Attempting to execute interactive functions from within an event handler can cause serious problems, as AutoCAD may still be processing a command at the time the event is triggered. Therefore, you should always avoid requesting for input at the Command prompt, as well as object selection requests, and using the SendStringToExecute method from within event handlers.
Dialog boxes are considered interactive functions and can interfere with the current operation of AutoCAD. Message boxes and alert boxes are not considered interactive and can be issued safely; however issuing a message box within some event handlers such as EnterModal, LeaveModal, DocumentActivated, and DocumentToBeDeactivated can result in unexpected sequencing.
Obviously, any object causing an event to be triggered could still be open and the operation currently in progress. Therefore, avoid modifying an object from an event handler for the same object. However, you can safely read information from the object triggering an event.
If you perform the same action in an event handler that triggers that same event, you will create an infinite loop. For example, you should never attempt to open an object from within the ObjectOpenedForModify event, or AutoCAD will simply continue to open objects.