Right from the start, I think the reason it's hanging is because your progress bar is likely OWNED by another thread. Like others have stated, you might want to reconsider your design here.
A way to invoke updates to a GUI element made by another thread is to make an invoker delegate. The following code illustrates an update method to a label which is designed to display the current time.
Also, a matter of personal preference is that anonymous threads are like loose canons. They're great for executing some very simple, one-time operation. But if it's to continuously update a UI element, I'd advise against their use in this case.
private delegate void StatusCallbackString(string someText);
.
.
.
private void updateUITime(string time)
{
if (lblTime.InvokeRequired)
{
StatusCallbackString sCB = new StatusCallbackString(updateUITime);
this.BeginInvoke(sCB, new object[] { time });
return;
}
lblTime.Text = time;
}
Meanwhile, in a background thread somewhere...
private void MyThreadedOperation()
{
while(keepThreadAlive)
{
updateUITime(DateTime.Now.ToString());
.
.
System.Threading.CurrentThread.Join(1000);
}
}