유튜브 다운 로더를 만들면서 WebClient.DownloadFileAsync
을 사용하고 있습니다. 문제가 있습니다. C#에서 DownloadFileAsync 이후에 다음 코드를 실행할 수 없습니까?
WebClient client = new WebClient();
Process.Text("", "Downloading video data...", "new");
client.DownloadFileAsync(new Uri(this.VidLink), this.path + "\\tempVid"); // Line3
Process.Text("", "Downloading audio data...", "old");
client.DownloadFileAsync(new Uri(this.AudLink), this.path + "\\tempAud"); // Line5
FFMpegConverter merge = new FFMpegConverter();
merge.Invoke(String.Format("-i \"{0}\\tempVid\" -i \"{1}\\tempAud\" -c copy \"{2}{3}\"", this.path, this.path, dir, filename)); // Line8
merge.Stop();
Process.Text("", "Video merging complete", "new");
Process
DownloadFileAsync
대신
DownloadFile
을 사용하면 코드가 잘 작동하므로
this.AudLink
은 문제가되지 않습니다. 또한 Line 5를 삭제하면 Line 5도 잘 작동합니다.
마찬가지로 Line 3을 삭제하면 Line 5가 잘 처리됩니다. Line 8은 실행되지 않습니다. 그렇다면이 코드의 문제점은 무엇입니까? client
등으로 사용되는 프로세스를 죽여야합니까?
++) 비디오 데이터를 다운로드하는 동안 youtube-dl
을 사용하지 않으므로 대신 youtube-dl을 사용하지 마십시오.
당신은해야을
await
수'당신의 비동기 호출을 await'ing, 또는 완료시기를 결정하는 다른 방법을 사용하여. – Jamiec@Jamiec 코드 스 니펫이 불완전하거나 올바르지 않다면 같은 것을 궁금해하고 있습니다 .. 또는 기다릴 수있는 모든 메서드는 .Result를 호출 할 수 있지만 그다지 조언하지는 않습니다. – rmjoia
은 webClient의 두 가지 객체를 기다리거나 시도하거나 다른 작업에서 수행하고 Task1을 사용합니다. 다른 사람과 계속하십시오. – Amit