private static async void libraryInContext(DocumentCollection dc, Editor ed) { // Protect the command-calling function with a flag to avoid // eInvalidInput failures if (!_drawing) { _drawing = true; // Call our square creation function asynchronously await dc.ExecuteInCommandContextAsync(async (o) => LibraryAction(ed), null); _drawing = false; } }