andrew4582

actionInvoke<T> (WinForm) - Invokes an Action<T> if control's property 'InvokeRequired' is true, otherwise just calls the action

Dec 16th, 2011
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.33 KB | None | 0 0
  1.     Control actionParameter = default(Control);
  2.     Action<Control> actionInvoke = (val) => {
  3.  
  4.         //do ui thread protected logic here
  5.  
  6.         if(val == default(Control))
  7.             return;
  8.  
  9.  
  10.     };
  11.     if(InvokeRequired)
  12.         Invoke(actionInvoke,actionParameter);
  13.     else
  14.         actionInvoke(actionParameter);
Advertisement
Add Comment
Please, Sign In to add comment