I have a scripting language implemented in WPF that allows a user to script multiple concurrent actions. These actions are implemented using async/await and all of them run on the main thread.
I'm now introducing a step debugger into this script language. Currently, there is one window associated with the script engine and a different window for the step debugger.
I'm trying to accomplish stopping processes in the engine window just before a scripted action executes while not blocking interactivity on the debugger window. MessageBox.Show() works great for this especially because it pauses animations which may themselves start new actions on completion.
Thread.Sleep() of course doesn't work at all because everyone is on the main thread.
Is there a pausing mechanism in C# similar to MessageBox.Show() but with no UI? I've tried calling Dispatcher.DisableProcessing() which I could have sworn worked to pause the engine window, but now I get the error:
'Dispatcher processing has been suspended, but messages are still being processed'
I think ideally I'd like to do something like this:
//Engine Window
private debugger;
void RunAction(ScriptAction action){
if(action.BreakPoint){
var pauserObject = PauseProcessesOnThisWindow();
debugger.break(action, pauseObject);
}
}
//Debugger Window
void Continue_Click(){
pauseObject.release();
}
If I have to go with the MessageBox approach, I can see that closing it from the other window can be tricky, not to mention that it's an awkward UI to have some control in the debugger window but still require the user to close the box from the engine window.