private void SetProgressBarParams(ProgressBar pb, int minimum, int maximum, int step) { // 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 (pb.InvokeRequired) { SetProgressBarParamsCallback d = new SetProgressBarParamsCallback(SetProgressBarParams); pb.BeginInvoke(d, new object[] { pb, minimum, maximum, step }); } else { pb.Minimum = minimum; pb.Maximum = maximum; pb.Step = step; } }