473,383 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

im trying to use event to check when the file download is completed but its not work

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:

Expand|Select|Wrap|Line Numbers
  1. if (fdt.http_test()== true)
  2.             {               
  3.                     Client.DownloadFile(remote_image_on_server, temp_dir + temp_file);
  4.                     label6.Enabled = true;
  5.                     label6.Visible = true;
  6.                     label6.Text = "Internet connection active";               
  7.             }
  8.             else
  9.             {
  10.                 Logger.Write("Connection to the internet has failed");
  11.                 button1.Enabled = true;
  12.                 timer1.Enabled = false;
  13.                 label6.Enabled = true;
  14.                 label6.Visible = true;
  15.             }
  16.  
Now i tried to register to this event:

Expand|Select|Wrap|Line Numbers
  1. Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted);
  2.  

And i added this line to the internet connection checking after this line Client.DownloadFile(remote_image_on_server, temp_dir + temp_file);
So it looks like:

Expand|Select|Wrap|Line Numbers
  1. if (fdt.http_test()== true)
  2.             {               
  3.                     Client.DownloadFile(remote_image_on_server, temp_dir + temp_file);
  4.                     Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted);
  5.                     label6.Enabled = true;
  6.                     label6.Visible = true;
  7.                     label6.Text = "Internet connection active";               
  8.             }
  9.  
Then in the end of the form1 code i created manualy the event function like this:

Expand|Select|Wrap|Line Numbers
  1. private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs  e)
  2.          {
  3.              MessageBox.Show("file downloaded in: ");  
  4.          }
  5.  
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:

Expand|Select|Wrap|Line Numbers
  1. Client.DownloadFileCompleted +=
  2. new AsyncCompletedEventHandler(Client_DownloadFileCompleted); 
  3.  
  4. Client.DownloadFileAsync(new Uri(satellite_address), temp_dir + satellite_file_name);
  5.  
Instead Client.DownloadFile so Client.DownloadFileAsync

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?
Sep 26 '10 #1
0 1069

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
2
by: Pedro Fonseca | last post by:
Greetings! In my PHP website I'm trying to raise a File Download dialog directly in a WindowsCE IE client with the following code: header( "Content-Type: application/octet-stream\n" );...
8
by: IGC | last post by:
I have a requirement to record in a database when a file is finished downloading to the end-user. Currently when a user clicks a download icon for a file it directs to an ASP page that records the...
0
by: jmd | last post by:
Hello. I want to write a C# program that does completely automatically what, until now, I do manually, witch is describe below : 1. I launch IE (6) 2. I browse to my desired download page, say...
0
by: Buddy Ackerman | last post by:
I am trying to implment a file download via a link such that when clicked, instead of starting the default application for that type of file the user will be presented with a download dialog...
0
by: JD | last post by:
Hello Everyone, I am trying to set up a media kit page where when a user comes to the page for the first time and click on the image they wish to download they are brought to a registration...
2
by: Dan D | last post by:
I have a large install file (an exe) on my web server that people download and install from. Looking at my log files, I see a lot of people downloading it, but no way to tell for sure if they...
5
by: Dan D | last post by:
I have a large install file (an exe) on my web Apache server that people download and install from. Looking at my log files, I see a lot of people downloading it, but no way to tell for sure if...
1
by: test | last post by:
I'm trying to develop a small inhouse file download tool I need to detect all files downloaded from internetexplorer and display a custom interface i.e. when ever the user tries to download a file...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.