UIHelper 类
static public class UIHelper
{
/// <summary>
/// Access the GUI thread
/// </summary>
/// <param name="control"></param>
/// <param name="code"></param>
static public void InvokeOnUIifRequired(Control control, MethodInvoker code)
{
if (control.InvokeRequired && control.Visible == true)
{
control.Invoke(code);
}
else
{
code.Invoke();
}
/*Thread t = new Thread(new ThreadStart(delegate()
{
CrossThread cross = delegate()
{
control.Refresh();
};
control.Invoke(cross);
}));*/
}
}
使用:
UIHelper.InvokeOnUIifRequired(this, delegate
{
TempPictureBox.Image = img;
});
public delegate void Delegate_UpdateChannel(int iIndex);//0--15