You can just remove all of your code to push it to another thread and lose nothing, without blocking your UI. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow.
Learn more. How to download multiple files using webclient and threading? Ask Question. Asked 7 years, 5 months ago. Active 7 years, 5 months ago. Viewed 4k times. Sam 7, 15 15 gold badges 44 44 silver badges 65 65 bronze badges.
Vico Ervanda Vico Ervanda 43 1 1 silver badge 10 10 bronze badges. There is no need to use threads here at all. When the program enters the download complete handle I am finding the file information contained in the response header for the sender object ResponseHeaders["Content- Dispositio n"] , is different than the file in the AsyncCompletedEventHandler.
What I expected was completed events to be fired for each download request, but it looks like the completed event is using the first or the last request as the sender and eventually the sender value changes to null. As noted earlier, the sender never matches the event arg UserState. If I download 1 file at a time, no problems - the response header content matches the UserState object. Any ideas on what I am doing wrong would be greatly appreciated. Thanks in advance.
Todd Gerbert. Most Points The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics. Join our community to see this answer! We will create a simple UI that allows downloading multiple files in c as shown below. C Download multiple files with progress bar You can easily create a c download file from server using the WebClient class without using any third party libraries. DefaultNetworkCredentials; client. GetFileName uri.
LocalPath ; await client. Net Assembly: System. Downloads the resource with the specified URI to a local file. DownloadFile Uri, String. Note This member outputs trace information when you enable network tracing in your application. Applies to. DownloadFile String, String. Is this page helpful? In this article.
0コメント