used breakpoint on the event but its never get there.
This is the code of the connection testing of the internet while downloading the file in the contrustor:
Now i tried to register to this event:
And i added this line to the internet connection checking after this line Client.Download File(remote_ima ge_on_server, temp_dir + temp_file);
So it looks like:
Then in the end of the form1 code i created manualy the event function like this:
But the event never get to the MessageBox.Show ("file downloaded in: "); i used breakpoint on the MessageBox and it never get there.
What did i do wrong? Or how should i do it so it will show something like " The file have been downloaded in: 3 seconds " ?
Thanks.
Ok i found how to make the event to be raised.
I added this two files in the constructor to the code i showed above:
Instead Client.Download File so Client.Download FileAsync
The problem is how do i make the application in the constructor to wait for the event to be raised before it continue?
Cuz i used breakpoint on this lines and its continue on the constructor and only when the application is finished loading im getting the messagebox of the event. I want to get the messagebox of the event before the application is loaded. When it start to download so it will wait raise the event tell me its finished and only then continue loading the rest of the application in the constructor.
How can i do it?
This is the code of the connection testing of the internet while downloading the file in the contrustor:
Code:
if (fdt.http_test()== true) { Client.DownloadFile(remote_image_on_server, temp_dir + temp_file); label6.Enabled = true; label6.Visible = true; label6.Text = "Internet connection active"; } else { Logger.Write("Connection to the internet has failed"); button1.Enabled = true; timer1.Enabled = false; label6.Enabled = true; label6.Visible = true; }
Code:
Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted);
And i added this line to the internet connection checking after this line Client.Download File(remote_ima ge_on_server, temp_dir + temp_file);
So it looks like:
Code:
if (fdt.http_test()== true) { Client.DownloadFile(remote_image_on_server, temp_dir + temp_file); Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted); label6.Enabled = true; label6.Visible = true; label6.Text = "Internet connection active"; }
Code:
private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { MessageBox.Show("file downloaded in: "); }
What did i do wrong? Or how should i do it so it will show something like " The file have been downloaded in: 3 seconds " ?
Thanks.
Ok i found how to make the event to be raised.
I added this two files in the constructor to the code i showed above:
Code:
Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted); Client.DownloadFileAsync(new Uri(satellite_address), temp_dir + satellite_file_name);
The problem is how do i make the application in the constructor to wait for the event to be raised before it continue?
Cuz i used breakpoint on this lines and its continue on the constructor and only when the application is finished loading im getting the messagebox of the event. I want to get the messagebox of the event before the application is loaded. When it start to download so it will wait raise the event tell me its finished and only then continue loading the rest of the application in the constructor.
How can i do it?