Created
November 2, 2018 11:25
-
-
Save jaydeepkarena/c4746350da843c5250bf1fa03af9e241 to your computer and use it in GitHub Desktop.
C# Extension Method - InvokeIfRequired - use while updating control from different thread
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void InvokeIfRequired<T>(this T control, Action<T> action) where T : Control | |
{ | |
if (control.InvokeRequired) | |
{ | |
control.Invoke(new Action(() => action(control))); | |
} | |
else | |
{ | |
action(control); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment