narasimman g

narasimman g

  • 1.6k
  • 160
  • 351.7k

Progress bar is not running

Dec 13 2010 11:03 PM

Hi All,
 
Am using a delegate
delegate
void MyDelegate(bool show);
and accessing delegate using
Invoke(
new MyDelegate(ShowProgressBar), true);
public void ShowProgressBar(bool show)
{
Progressbar1.Visible = show;

}
I need to run another function on button click
btnstart_click
{
Invoke(new MyDelegate(ShowProgressBar), true);
RunProgressbarfunction();
Invoke(new MyDelegate(ShowProgressBar), false);
}
Problem is Runprogressbarfunction accessing Form controls and assigning values for properties on run time (i.e. label1.visible=true;) and getting the below error.I have peeped thru google.Tried all methods still showing the same error.anyone could  resolved this?

Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on.

Answers (1)