DownloadfileCompleted event
-
Hello All, I have a problem with event that I am generating after file download. The flow is like this 1.initialize the DownloadfileCompleted event handler. 2.DownloadFileAsync(URI,str2) 3.After download completed it should display "download complete" 4.return "downloaded successfully" but the problem is if the downloading takes more time it is directly coming to step 4. without waiting for completeion of step 3. how can i make step 4 to wait until completeion of step3.. Thanks in Advance, Ashok
ashok
-
Hello All, I have a problem with event that I am generating after file download. The flow is like this 1.initialize the DownloadfileCompleted event handler. 2.DownloadFileAsync(URI,str2) 3.After download completed it should display "download complete" 4.return "downloaded successfully" but the problem is if the downloading takes more time it is directly coming to step 4. without waiting for completeion of step 3. how can i make step 4 to wait until completeion of step3.. Thanks in Advance, Ashok
ashok
-
1. objWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(Event_DownloadFileCompleted); 2.objWebClient.DownloadFileAsync(new Uri(p_strSourcePath), l_strDestinationPath); 3.MessageBox.Show("Updated Successfully"); 4.public void Event_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { MessageBox.Show("Download Completed"); }
ashok
-
1. objWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(Event_DownloadFileCompleted); 2.objWebClient.DownloadFileAsync(new Uri(p_strSourcePath), l_strDestinationPath); 3.MessageBox.Show("Updated Successfully"); 4.public void Event_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { MessageBox.Show("Download Completed"); }
ashok
-
1. objWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(Event_DownloadFileCompleted); 2.objWebClient.DownloadFileAsync(new Uri(p_strSourcePath), l_strDestinationPath); 3.MessageBox.Show("Updated Successfully"); 4.public void Event_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { MessageBox.Show("Download Completed"); }
ashok
To make it block the execution;
public bool downloadIsDone = false;
public void ZeDownloadMechanism()
{
objWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(
Event_DownloadFileCompleted);objWebClient.DownloadFileAsync(new Uri(p_strSourcePath), l_strDestinationPath);
while (!downloadIsDone)
Application.DoEvents();MessageBox.Show("Updated Successfully");
}public void Event_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
downloadIsDone = true;
MessageBox.Show("Download Completed");
}Why would you want to block execution on a Async-download?
I are troll :)
-
To make it block the execution;
public bool downloadIsDone = false;
public void ZeDownloadMechanism()
{
objWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(
Event_DownloadFileCompleted);objWebClient.DownloadFileAsync(new Uri(p_strSourcePath), l_strDestinationPath);
while (!downloadIsDone)
Application.DoEvents();MessageBox.Show("Updated Successfully");
}public void Event_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
downloadIsDone = true;
MessageBox.Show("Download Completed");
}Why would you want to block execution on a Async-download?
I are troll :)
-
ThanQ for your help, can u brief the differences between normal download and async-download?
ashok
Sync (normal) blocks execution, Async doesn't. Simple example, if you normally play a soundfile in VB6, then the computer will not execute anything until the sound is finished playing. If you play it async, the computer will "move on", and execute your next instruction. Hope this helps :)
I are troll :)