0
다른 스레드의 FTP 서버에서 파일을 다운로드하고 싶습니다. 문제는이 스레드가 내 응용 프로그램이 정지되었음을 의미합니다. 여기에 코드가 있는데, 내가 뭘 잘못하고 있니? 어떤 도움에 의해합니다 감사합니다 :)MyThread.Join()은 전체 응용 프로그램을 차단합니다. 왜?
(물론 내가 'ReadBytesThread'종료 스레드 때까지 반복 중지합니다.) 내가 새 스레드 만들기 : 당신이 차에 DownloadFiles
를 호출하고
DownloadThread = new Thread(new ThreadStart(DownloadFiles));
DownloadThread.Start();
private void DownloadFiles()
{
if (DownloadListView.InvokeRequired)
{
MyDownloadDeleg = new DownloadDelegate(Download);
DownloadListView.Invoke(MyDownloadDeleg);
}
}
private void Download()
{
foreach (DownloadingFile df in DownloadingFileList)
{
if (df.Size != "<DIR>") //don't download a directory
{
ReadBytesThread = new Thread(() => {
FileData = sendPassiveFTPcmd("RETR " + df.Path + "/" + df.Name + "\r\n");
FileStream fs = new FileStream(@"C:\Downloads\" + df.Name, FileMode.Append);
fs.Write(FileData, 0, FileData.Length);
fs.Close();
});
ReadBytesThread.Start();
(here->) ReadBytesThread.Join();
MessageBox.Show("Downloaded");
}
}
}