/// <summary> /// Runs an action as soon as the engine is not busy and no /// game message box is onscreen. /// </summary> /// <param name="action"></param> internal void BeginRunOnIdle(Action action) { // Wraps the action in a dispatcher action. Action wrapper = new Action(() => { App.Current.RootFrame.Dispatcher.BeginInvoke(action); }); // If the engine is idle, runs the action immediately. if (!Model.Core.IsBusy && !MessageBoxManager.HasMessageBox) { wrapper(); } else { _actionPump.AcceptAction(wrapper); } }