diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index d6da2ff706..68ce23e206 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -1675,7 +1675,13 @@ namespace BizHawk.MultiClient if (LuaConsole1.IsRunning()) { Global.MainForm.MainWait.Set(); - LuaConsole1.WaitOne(); + for (; ; ) + { + //we need to run DoEvents in here so that we can use Control.Invoke to interact with the gui + //its all a godawful mess + if (LuaConsole1.WaitOne(10)) break; + Application.DoEvents(); + } } #endif diff --git a/BizHawk.MultiClient/tools/LuaConsole.cs b/BizHawk.MultiClient/tools/LuaConsole.cs index 60b3266506..963ffc1a10 100644 --- a/BizHawk.MultiClient/tools/LuaConsole.cs +++ b/BizHawk.MultiClient/tools/LuaConsole.cs @@ -592,8 +592,11 @@ namespace BizHawk.MultiClient if (!OutputBox.IsHandleCreated || OutputBox.IsDisposed) return; - OutputBox.Text += message; - OutputBox.Refresh(); + OutputBox.Invoke(() => + { + OutputBox.Text += message; + OutputBox.Refresh(); + }); } public void ClearOutputWindow() @@ -601,8 +604,11 @@ namespace BizHawk.MultiClient if (!OutputBox.IsHandleCreated || OutputBox.IsDisposed) return; - OutputBox.Text = ""; - OutputBox.Refresh(); + OutputBox.Invoke(() => + { + OutputBox.Text = ""; + OutputBox.Refresh(); + }); } private void openToolStripMenuItem_Click_1(object sender, EventArgs e) @@ -694,12 +700,12 @@ namespace BizHawk.MultiClient } } - public void WaitOne() + public bool WaitOne(int timeout) { if (!this.IsHandleCreated || this.IsDisposed) - return; + return true; - this.LuaImp.LuaWait.WaitOne(); + return this.LuaImp.LuaWait.WaitOne(timeout); } private void openToolStripButton_Click(object sender, EventArgs e) diff --git a/BizHawk.Util/BizHawk.Util.csproj b/BizHawk.Util/BizHawk.Util.csproj index e0b1e9c742..1c587d6b34 100644 --- a/BizHawk.Util/BizHawk.Util.csproj +++ b/BizHawk.Util/BizHawk.Util.csproj @@ -129,6 +129,7 @@ Component + Component @@ -185,4 +186,4 @@ --> - + \ No newline at end of file diff --git a/BizHawk.Util/Util.cs b/BizHawk.Util/Util.cs new file mode 100644 index 0000000000..2c7fae5eea --- /dev/null +++ b/BizHawk.Util/Util.cs @@ -0,0 +1,22 @@ +using System; +using System.Windows.Forms; +using System.Linq; +using System.Reflection; +using System.Diagnostics; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text; + +namespace BizHawk +{ + public static class Extensions + { + //extension method to make Control.Invoke easier to use + public static void Invoke(this Control control, Action action) + { + control.Invoke((Delegate)action); + } + } +} \ No newline at end of file