diff --git a/src/RhinoInside.Revit.AddIn/Loader.cs b/src/RhinoInside.Revit.AddIn/Loader.cs index 56ec05042..e2f90c451 100644 --- a/src/RhinoInside.Revit.AddIn/Loader.cs +++ b/src/RhinoInside.Revit.AddIn/Loader.cs @@ -121,8 +121,16 @@ static async void CheckForUpdates() #endregion #region IHostedApplication - void ERUI.IHostedApplication.InvokeInHostContext(Action action) => Rhinoceros.InvokeInHostContext(action); - T ERUI.IHostedApplication.InvokeInHostContext(Func func) => Rhinoceros.InvokeInHostContext(func); + void ERUI.IHostedApplication.InvokeInHostContext(Action action) + { + if (Core.CurrentStatus == Core.Status.Ready) Rhinoceros.InvokeInHostContext(action); + else action(); + } + T ERUI.IHostedApplication.InvokeInHostContext(Func func) + { + if (Core.CurrentStatus == Core.Status.Ready) return Rhinoceros.InvokeInHostContext(func); + else return func(); + } bool ERUI.IHostedApplication.DoEvents() => Rhinoceros.Run(); Microsoft.Win32.SafeHandles.WindowHandle ERUI.IHostedApplication.MainWindow => Rhinoceros.MainWindow;