一次为超过 1 个项目调用 MethodInvoker Delegate
Invoke MethodInvoker Delegate for more than 1 item at a time
下面的代码工作得很好,但我正在寻找一种方法将所有 3 个组合成一个 invoke 语句:
this.Invoke(new MethodInvoker(delegate () {
String.Format(
"------------------------------------------------------------")
);
}));
this.Invoke(new MethodInvoker(delegate () {
String.Format(
"- END " + archiveFullName + " -"
);
}));
this.Invoke(new MethodInvoker(delegate () {
String.Format(
"------------------------------------------------------------")
);
}));
我已经试过了:
this.Invoke(new MethodInvoker(delegate () {
listBox1.Items.Add(
this.listBox1.Items.Add("--------------------------------------------------------")
this.listBox1.Items.Add("- END " + archiveFullName + " -")
this.listBox1.Items.Add("-------------------------------------------------------")
);
}));
但这似乎不起作用。
任何分辨率都很好!
使用AddRange方法。
listBox1.Items.AddRange(...
下面的代码工作得很好,但我正在寻找一种方法将所有 3 个组合成一个 invoke 语句:
this.Invoke(new MethodInvoker(delegate () {
String.Format(
"------------------------------------------------------------")
);
}));
this.Invoke(new MethodInvoker(delegate () {
String.Format(
"- END " + archiveFullName + " -"
);
}));
this.Invoke(new MethodInvoker(delegate () {
String.Format(
"------------------------------------------------------------")
);
}));
我已经试过了:
this.Invoke(new MethodInvoker(delegate () {
listBox1.Items.Add(
this.listBox1.Items.Add("--------------------------------------------------------")
this.listBox1.Items.Add("- END " + archiveFullName + " -")
this.listBox1.Items.Add("-------------------------------------------------------")
);
}));
但这似乎不起作用。
任何分辨率都很好!
使用AddRange方法。
listBox1.Items.AddRange(...