Answers for "Automating the InvokeRequired code pattern"

0

Automating the InvokeRequired code pattern

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();
    }
}


/// oder so
richEditControl1.InvokeIfRequired(() =>
{
    // Do anything you want with the control here
    richEditControl1.RtfText = value;
    RtfHelpers.AddMissingStyles(richEditControl1);
});
Posted by: Guest on September-29-2020

Code answers related to "Automating the InvokeRequired code pattern"

Browse Popular Code Answers by Language