fix lua poop

This commit is contained in:
zeromus 2012-03-17 23:40:30 +00:00
parent 338f4230f1
commit d0354fd1fe
4 changed files with 44 additions and 9 deletions

View File

@ -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

View File

@ -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)

View File

@ -129,6 +129,7 @@
<Compile Include="ToolStripEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Util.cs" />
<Compile Include="ViewportPanel.cs">
<SubType>Component</SubType>
</Compile>
@ -185,4 +186,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

22
BizHawk.Util/Util.cs Normal file
View File

@ -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);
}
}
}