C#线程问题,为什么我上传多个文件时它总是上传两个就重复第二个其它的不传了
string[] path;
//窗体加载
private void ftp_Load(object sender, EventArgs e)
{
openFileDialog1.Multiselect = true;
openFileDialog1.Filter = "WAV files (*.wav)|*.wav|All files (*.*)|*.* ";
}
//浏览
private void button1_Click(object sender, EventArgs e)
{
this.openFileDialog1.ShowDialog();
path = this.openFileDialog1.FileNames;
}
//文件上传
private void button2_Click(object sender, EventArgs e)
{
this.lbl_ftpStakt.Text = "连接服务器... ";
this.lbl_ftpStakt.Visible = true;
for (i = 0; i < path.Length; i++)
{
filename = path[i].ToString();
Thread tThread = new Thread(new ThreadStart(RunsOnWorkerThread));
tThread.Start();
FileInfo p = new FileInfo(path[i].ToString());
// MessageBox.Show(p.Name);
}
}
private void RunsOnWorkerThread()
{
mt.WaitOne();
Interlocked.Increment(ref flag);
this.lbl_ftpStakt.Text = "连接服务器中... ";
&nbs