Demand-loading is where you register an ARX extension
to be loaded automatically when one of the commands
it implements is first invoked.
For handling events, you can't use demand loading because
there's no way to tell AutoCAD that an extension should be
loaded when an event occurs.
So, you must load at startup for event-driven applications.
You don't have to explicitly NETLOAD your app, you can
also register it to load when AutoCAD starts as well. There
should be something on Kean's blog that shows how to do
that, but I don't have any specific links handy.
Typically, the pattern involves using IExtensionApplication
to have AutoCAD call your assembly when it loads, where
you can add handlers for application-level events.
For document-level events, you must add handlers for the
DocumentCollection's DocumentAdded/ToBeDestroyed events,
and in the handlers of those events, you add/remove handlers
for document-level events.
The specific example that you gave, would be fairly complicated,
because it would involve handling selection-based events, and
in those events, you would check to see what command is in-
progress, and act accordingly. The Editor class exposes events
that allow you to examine the objects selected by the user, and
even add/remove them.
The example case you describe might be more easily done by
simply implementing an alternative command that can be used
in lieu of the built-in command.
Demand loading isn't something we can somehow appent to a native command, is it?
I saw Kean's blog about selecting too many entities and the some alternative options dialog that ensues. I'll dig it up and report back with modified questions.