WebClient.DownloadFileAsync method
Hi, I wrote a program that need to download on demend a file from a given url. I built a download form that gets the url and the file path to save and it shows a progress bar. The path and filename are given to the form on the c'tor and the download itself starts when a method is being called.
Here is the code: (It is written in VS2005 beta 2)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Net; using System.IO; using System.Diagnostics; namespace TechnoTask.View { private String filepath; private String directory; private WebClient client; public DownloadWin(String link,String path, String file) { void client_DownloadFileCompleted(object sender, void client_DownloadProgressChanged(object sender, privatevoid cancel_Click(object sender, EventArgs e) { publicvoid startDownload() { privatevoid openDir_Click(object sender, EventArgs e) { |
The problem is that the download stucks the viewing of the form for 4 seconds or so and what I get is a semi complete form and the whole program is stuck (other forms also) after the initial stuck the program continue to function and the form is viewed. I don't mind the program halt but I want the form to finish it's drawing before it is stuck (fixing the halt would be even better).
I'm not using threads but the DownloadFileAsync should not stop the program (or is it?).
If you have suggestions please tell me.

