private void PercentStatus(string text, int percent) { // 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 (logBox.InvokeRequired) { PercentStatusCallback d = new PercentStatusCallback(PercentStatus); this.Invoke(d, new object[] { text, percent }); } else { statusLabel.Text = "status: " + text + " (" + percent + "%)"; progressBar1.Value = percent; } }