Then after it i want to show a progressBar on the screen from the time the splash screen have been closed untill the application is loaded.
This is the code in the constructor of Form1 of the splash screen and the backgroundWorker:
Expand|Select|Wrap|Line Numbers
- while (splash_flag == true)
- {
- splash.Show();
- Thread.Sleep(3000);
- splash_flag = false;
- }
- if (splash_flag == false)
- {
- splash.Close();
- }
- myProgressBar2 = new ProgressBar();
- {
- myProgressBar2.Maximum = 100;
- backgroundWorker1.WorkerReportsProgress = true;
- backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
- backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
- backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
- };
- backgroundWorker1.RunWorkerAsync(myProgressBar2);
Now here is the functions of the backgroundWorker on the bottom of Form1 code:
Firs the backgroundWorker1_DoWork:
Expand|Select|Wrap|Line Numbers
- private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
- {
- for (int i = 0; i < 100; i++)
- {
- Thread.Sleep(100);
- backgroundWorker1.ReportProgress(i);
- }
- }
Expand|Select|Wrap|Line Numbers
- private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) //call back method
- {
- myProgressBar2.Value = e.ProgressPercentage;
- }
- private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) //call back method
- {
- myProgressBar2.Value = progressBar1.Maximum;
- }
I want that while the form1 making connection tests to the internet it will show me how long it takes to the application to load.
This is the code of the backgroundWorker with the internet connection tests this time.
I want that after the splash screen when its making internet connection tests so it will show me in this time how much time left to load the application:
Expand|Select|Wrap|Line Numbers
- myProgressBar2 = new ProgressBar();
- {
- myProgressBar2.Maximum = 100;
- backgroundWorker1.WorkerReportsProgress = true;
- backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
- backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
- backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
- };
- backgroundWorker1.RunWorkerAsync(myProgressBar2);
- if (fdt.http_test() == true)
- {
- Client.DownloadFile(satellite_address, temp_dir + satellite_file_name);
- label6.Enabled = true;
- label6.Visible = true;
- label6.Text = "internet connection is active";
- }
- else
- {
- Logger.Write("Connection to the internet has failed");
- button1.Enabled = true;
- timer1.Enabled = false;
- label6.Enabled = true;
- label6.Visible = true;
- }
- if (fdt.satellite_test() == true)
- {
- Client.DownloadFile(satellite_address, temp_dir + satellite_file_name);
- label6.Enabled = true;
- label6.Visible = true;
- label6.Text = "internet connection is active";
- }
- else
- {
- Logger.Write("Connection to the internet has failed");
- button1.Enabled = true;
- timer5.Enabled = false;
- label6.Enabled = true;
- label6.Visible = true;
- }
- 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 is active";
- }
- else
- {
- Logger.Write("Connection to the internet has failed");
- button1.Enabled = true;
- timer1.Enabled = false;
- label6.Enabled = true;
- label6.Visible = true;
- }
Thanks.