Code:
private void UpdateProgressBar(int iCount)
{
      BeginInvoke((MethodInvoker)delegate()
        {
          // This runs on the UI thread!
          progressBar.Value = iCount;
        });
}
This usually does the trick for me.