简易delegate委托
Posted olerookie
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简易delegate委托相关的知识,希望对你有一定的参考价值。
#region 委托 /// <summary> /// 日志 /// </summary> /// <param name="s"></param> private delegate void MyAddLog(string str); private static event MyAddLog AddLog; private void EventAddLog(string msg) { tb_msg.AppendText(DateTime.Now.ToString("HH:mm:ss") + " " + msg + " "); } /// <summary> /// 监听总数 /// </summary> /// <param name="num"></param> private delegate void MyDeviceCount(int num); private static event MyDeviceCount DeviceCountChange; private void EventDeviceCount(int num) { label_jianting_count.Text = num.ToString(); } #endregion private void Form1_Load(object sender, EventArgs e) { CheckForIllegalCrossThreadCalls = false; //绑定委托 AddLog += EventAddLog; DeviceCountChange += EventDeviceCount; }
以上是关于简易delegate委托的主要内容,如果未能解决你的问题,请参考以下文章