You could use a custom class like RevitCommandEndedMonitor that uses the idling exactly like @jeremy_tammik suggests.
Where I found the reference: https://forums.autodesk.com/t5/revit-api-forum/a-question-about-suppressing-warning-messages-in-revi...
Here is my example: https://gist.github.com/ricaun/cc4f0a39b36006883f091bc7f0fc3d35
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Events;
using System;
namespace RevitAddin
{
[Transaction(TransactionMode.Manual)]
public class CommandMoveEnd : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
RevitCommandEndedMonitor revitCommandEndedMonitor = new RevitCommandEndedMonitor(uiapp);
revitCommandEndedMonitor.CommandEnded += OnCommandEnded;
uiapp.PostCommand(RevitCommandId.LookupPostableCommandId(PostableCommand.Move));
return Result.Succeeded;
}
private void OnCommandEnded(object sender, EventArgs e)
{
TaskDialog.Show("Revit", "Move End");
}
}
public class RevitCommandEndedMonitor
{
private readonly UIApplication _revitUiApplication;
private bool _initializingCommandMonitor;
public event EventHandler CommandEnded;
public RevitCommandEndedMonitor(UIApplication revituiApplication)
{
_revitUiApplication = revituiApplication;
_initializingCommandMonitor = true;
_revitUiApplication.Idling += OnRevitUiApplicationIdling;
}
private void OnRevitUiApplicationIdling(object sender, IdlingEventArgs idlingEventArgs)
{
if (_initializingCommandMonitor)
{
_initializingCommandMonitor = false;
return;
}
_revitUiApplication.Idling -= OnRevitUiApplicationIdling;
OnCommandEnded();
}
protected virtual void OnCommandEnded()
{
CommandEnded?.Invoke(this, EventArgs.Empty);
}
}
}
See yaa