Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to show a progress from i.e 'Please wait loading...' form while running a method in C#.

I have taken one button in that i have written one method code.when we click on that button then the progress form will open until method has in progress state.

C#
BackgroundWorker bg = new BackgroundWorker();
            bg.DoWork += new DoWorkEventHandler(bg_DoWork);
            bg.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted);
            // Start the worker.
            bg.RunWorkerAsync();
            // Display the loading form.
            popup pp = new popup();
            pp.ShowDialog();


C#
private void bg_DoWork(object sender, DoWorkEventArgs e)
      {
copy();
}


C#
private void bg_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
   {
   object result = e.Result;
   pp.Close();
   }


but it is being shown one error

Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on.
Posted
Comments
VR Karthikeyan 19-Oct-15 3:04am    
Which presentation technique you are using? Is it Windows Forms or WPF?
TarunKumarSusarapu 19-Oct-15 3:07am    
windows foms
sreeyush sudhakaran 19-Oct-15 3:32am    
Why don't you use ProgressBar control with in a splash screen?
TarunKumarSusarapu 19-Oct-15 4:59am    
I don't know how to use it Can u give me the brief explanation while running a method

1 solution

Hi, Refer the following articles to show progress dialog in Windows Forms while long process.
1. Progress Bars, Threads, Windows Forms, and You.
2. Show progress dialog during long process – C#.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900