FTP发送文件里的线程问题
在每次发送文件的时候,都调用SendFile方法,请问这样创建线程有问题吗?会释放掉之前创建的线程吗?
public DataForm DataForm
{
get;
set;
}
public void SendFile(string path)
{
Thread thread = new Thread(() => SendFileThread(path, DataForm DataForm));
thread.Start();
GC.Collect();
GC.Collect();
}
public void SendFileThread(string path, DataForm DataForm)
{
lock (this)
{
...ftp连接、发送、关闭连接
...通过DataForm里的一个函数,将发送信息反馈到窗体的ListBox里
}
}