private void SetProgressBarVisible(ToolStripProgressBar pb, bool value) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (statusStrip1.InvokeRequired) { SetProgressBarVisibleCallback d = new SetProgressBarVisibleCallback(SetProgressBarVisible); statusStrip1.BeginInvoke(d, new object[] { pb, value }); } else { pb.Visible = value; } }