private delegate void EnableButtonCallBack(string s);
..
this.Invoke(new EnableButtonCallBack(ApendText), “teststring”);
..
private void ApendText(string s)
{
richTextBox1.AppendText(s);
}
因为最近发现 delegate可简写的地方很多,上面似乎可以改成一句话完事,但是发现自己不知道怎么改。
求教,谢谢!!
------解决思路----------------------
用lambda表达式
this.Invoke( new EnableButtonCallBack(s =>
{
richTextBox1.AppendText(s);
}), "teststring");
------解决思路----------------------
this.Invoke((Action<string>)ApendText, "teststring");