title: progressBar separate thread
body: <p>I have question about progressbar show value.</p>
  
  <p>I have this main thread</p>
  
  <p><pre><code></p>
  
  <p>private void button1_Click(object sender, EventArgs e) 
  { 
  progress prog = new progress(); 
  progress.progressEvent += new progress.progressEventHandler(progressEvent); 
  for(int i=0;i&lt;100;i++) 
  { 
  Thread.Sleep(100); 
  prog.incA(); 
  } 
  } </p>
  
  <p>void progressEvent(object sender) 
  { 
  if (progressBar1.InvokeRequired) 
  { 
  //Tady mi to caka az kym nedobehne cyklus for a pak zacne tohleto fungovat 
  progressBar1.Invoke(new ChangeProgressBarValue(ProgressStep)); 
  } 
  else 
  { 
  ProgressStep(); 
  } 
  } </p>
  
  <p>public void ProgressStep() 
  { 
  progressBar1.PerformStep(); 
  } </p>
  
  <p>public class progress 
  { 
  private ThreadStart ts; 
  private Thread th; 
  private bool status = true; 
  public delegate void progressEventHandler(object sender); 
  public static event progressEventHandler progressEvent; 
  private int b,a = 0; </p>
  
  <p>public progress() 
  { 
  ts=new ThreadStart(go); 
  th = new Thread(ts); 
  th.IsBackground = true; 
  th.Start(); 
  } </p>
  
  <p>public void incA() 
  { 
  a++; 
  if(a==100) 
  status = false; 
  } </p>
  
  <p>private void go() 
  { 
  while (status) 
  { 
  if (a != b) 
  { 
  b = a; 
  if (progressEvent != null) 
  progressEvent(this); 
  } 
  } 
  th.Abort(); 
  } 
  } 
  </pre></code></p>
  
  <p>and my problem is IF start main thread and call IncA this method call event and in event is progressbar invoke
  and this invoke waiting to end main thread FOR</p>
  
  <p>why waiting?
  thx</p>