Automating the InvokeRequired code pattern

Lee’s approach can be simplified further public static void InvokeIfRequired(this Control control, MethodInvoker action) { // See Update 2 for edits Mike de Klerk suggests to insert here. if (control.InvokeRequired) { control.Invoke(action); } else { action(); } } And can be called like this richEditControl1.InvokeIfRequired(() => { // Do anything you want with the control … Read more