private void SetButtonEnabled(bool enabled) { // 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 (buttonConvert.InvokeRequired) { BooleanArgReturningVoidDelegate d = new BooleanArgReturningVoidDelegate(SetButtonEnabled); Invoke(d, new object[] { enabled }); } else { buttonConvert.Enabled = enabled; } }
// If the calling thread is the same as the thread that created // the TextBox control, the Text property is set directly. private void SetGrpBoxState(Boolean trueOrfalse) { // 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 (this.grpParams.InvokeRequired) { BooleanArgReturningVoidDelegate d = new BooleanArgReturningVoidDelegate(SetGrpBoxState); this.Invoke(d, new object[] { trueOrfalse }); } else { this.grpParams.Enabled = trueOrfalse; } }