标签:style blog color div new log ui c#
直接上例子:
void updateUI() { if (dateTimePicker1.InvokeRequired) { dateTimePicker1.Invoke((MethodInvoker)delegate { dateTimePicker1.Enabled = true; dateTimePicker1.Checked = false; }); } else { dateTimePicker1.Enabled = true; dateTimePicker1.Checked = false; } }
如果不用匿名委托,那就像下面这样:
delegate void update(); void updateUI() { if (dateTimePicker1.InvokeRequired) { dateTimePicker1.Invoke(new update(() => { dateTimePicker1.Enabled = true; dateTimePicker1.Checked = false; })); } else { dateTimePicker1.Enabled = true; dateTimePicker1.Checked = false; } }
标签:style blog color div new log ui c#
原文地址:http://www.cnblogs.com/leavind/p/C匿名委托.html