C#_Deleagate
--------------------------------------------------------------------------------------
/* Class */
--------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GUI_Form
{
public delegate void ctr_Invoke(string message, TextBox txtout);
public delegate void ctr_Invoke_Lable(string message, Label lblName);
class WriteMessageCallback
{
public void WriteMessage(string message, TextBox txtout)
{
if (txtout.InvokeRequired)
{
ctr_Invoke d = new ctr_Invoke(WriteMessage);
txtout.Invoke(d, new object[] { message, txtout });
}
else
{
if (txtout.Text.Length >= 1000000) txtout.Text = "";
//txtout.AppendText("\r\n" + message + "\r\n");
txtout.AppendText("\r\n" + "Msg >. " + message);
//this.txtTerm.AppendText(msg);
txtout.ScrollToCaret();
txtout.Focus();
}
}
public void WriteLable(string message, Label lblName)
{
if (lblName.InvokeRequired)
{
ctr_Invoke_Lable d = new ctr_Invoke_Lable(WriteLable);
lblName.Invoke(d, new object[] { message, lblName });
}
else
{
lblName.Text = message;
}
}
}
}
--------------------------------------------------------------------------------------
/* 델리케이트 */
WriteMessageCallback msg = new WriteMessageCallback();
String strtemp = "123"
msg.WriteMessage("0x" + strtemp, txtMessage);