private void SetText(string name)
{
txtResult.Text = name;
}
private void btnFind_Click(object sender, EventArgs e)
{
Thread th = new Thread(new ThreadStart(FindFile));
th.Start();
}
private void FindFile()
{
string[] m = Directory.GetDirectories(@"c:\\", txtFile.Text.Trim(), SearchOption.AllDirectories);
string s = "test";
Invoke(new SetStr(SetText), s);
}
以上可以运行在vs 2005 下;
但是下面的报错:
delegate void SetStr(string[] s);
private void SetText(string[] name)
{
for (int i = 0; i < name.Length; i++)
{
txtResult.Text = txtResult.Text + name[i] + "\n";
}
}
private void btnFind_Click(object sender, EventArgs e)
{
Thread th = new Thread(new ThreadStart(FindFile));
th.Start();
}
private void FindFile()
{
string[] m = Directory.GetDirectories(@"c:\\", txtFile.Text.Trim(), SearchOption.AllDirectories);
string s = "test";
Invoke(new SetStr(SetText), m); // 此处报错:"参数计数不匹配。" 请问怎样解决?
}