本例以实时更新一个TextBox中的内容为例。
首先给出工具类
public delegate void DelegateModel();//代理
static class C_UpdateInfor //实时更新进度
{
static public TextBox TB_Show;
public static void PUB_UpdateInfot(string IN_Information)
{
DelegateModel DM_Delegate = delegate ()
{
TB_Show.AppendText(IN_Information+ "\r\n");
TB_Show.ScrollToCaret();
};
TB_Show.Invoke(DM_Delegate);
}
}
使用前先确定要更新的TextBox
C_UpdateInfor.TB_Show = textBox1;
使用的时候直接调用
C_UpdateInfor.PUB_UpdateInfot("进度xxxxx");