giammin

Control.InvokeRequired snippet

Feb 25th, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.22 KB | None | 0 0
  1. //control: ISynchronizeInvoke
  2.  
  3. if (control.InvokeRequired)
  4. {
  5.     Action d = MethodToExec; //can use Action<T> or Func<T, TResult>
  6.     control.Invoke(d,null); //null are method parameters
  7. }
  8. else
  9. {
  10.     MethodToExec();
  11. }
Advertisement
Add Comment
Please, Sign In to add comment