Determine when Revit API is not available

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to detect when Revit is in Modify Mode. My plugin's user interface runs in its own thread (since it is running a Dockable web browser, similar to Jeremy's example plugin here). Currently, if a user clicks a button in our docked panel, then we raise a Revit ExternalEvent, then process it. That's fine, but if the user is in Edit Mode, then the ExternalEvent never gets executed and it looks to the user like our plugin is just unresponsive.
I know Revit disables the ribbon button, but the docked panel is still there and very much interactive. We'd like to gray out the button in our plugin when user is in Edit Mode. Second best would be to at least detect that we have no access to the Revit API due to Edit Mode and notify the user. Is there a way to detect this mode? The API is unresponsive in edit mode, so is there an event generated before Modify mode is entered?
A similar question was asked previously, however there never was a solution: https://forums.autodesk.com/t5/revit-api-forum/detecting-modify-mode-aka-edit-mode/td-p/5616006 .