Pattern for Semi-Asynchronous Idling API Access

Here is another wonderful contribution from Daren Thomas: A Pattern for Asynchronously Updating Revit Documents.

As an attentive reader of this blog, you will certainly remember one of my favourite and most powerful recent projects, the modeless loose connector navigator. It retrieves and displays a list of unconnected MEP connectors in a modeless dialogue box. Being modeless, the dialogue is not within the context of a Revit external command Execute method, nor any other Revit API call-back, and thus has no access to the Revit API, which does not permit asynchronous access. Happily, the Idling event provides a workaround for that.

The modeless loose connector navigator demonstrates a solution for handling a very specialised need, accessing the Revit API semi-asynchronously to highlight the elements with loose connectors.

Daren's post generalises this solution, allowing a modeless dialogue to queue up a whole collection of actions to be taken, which can then be picked up and processed by the Idling event handler the next time it becomes active. A wonderful generic solution, including neat features such as:

A truly beautiful job, Daren. Thank you!