请高人改错:一个关于多线程的问题
void BtnBrowserClick(object sender, EventArgs e)
{
Thread uploadFile = new Thread(new ThreadStart(FtpUpFile));
uploadFile.Start(dlg.FileName);//dlg.FileName已经在全局变量中赋值了
}
private void FtpUpFile(string strFileName)
{
MessageBox.Show(strFileName);
}
运行的时候报的错误:“FtpUpFile”的重载均与委托“System.Threading.ThreadStart”不匹配
请问高人如何改错?
------解决方案--------------------void BtnBrowserClick(object sender, EventArgs e)
{
Thread uploadFile = new Thread(new ThreadStart(FtpUpFile));
uploadFile.Start(dlg.FileName);//dlg.FileName已经在全局变量中赋值了
Thread uploadFile = new Thread(new ThreadStart(FtpUpFile)); //不能有参数
uploadFile.Start();
}
private void FtpUpFile()
{
MessageBox.Show(strFileName);
}
------解决方案--------------------void BtnBrowserClick(object sender, EventArgs e)
{
Thread uploadFile = new Thread(FtpUpFile);
uploadFile.Start(dlg.FileName);//dlg.FileName已经在全局变量中赋值了
}
private void FtpUpFile(string strFileName)
{
MessageBox.Show(strFileName);
}
------解决方案--------------------FtpUpFile的函数应该定义为:private void FtpUpFile(object state){...}