Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Extension(), DebuggerHidden()>
- Public Sub InvokeIfRequired(control As Control, action As MethodInvoker)
- If control.InvokeRequired Then control.Invoke(action) Else action()
- End Sub
- ' No parameters
- <Extension(), DebuggerHidden()>
- Public Function InvokeIfRequired(Of TR)(control As Control, func As Func(Of TR)) As TR
- If control.InvokeRequired Then
- Return control.Invoke(func)
- Else
- Return func.Invoke()
- End If
- End Function
- ' One parameter
- <Extension(), DebuggerHidden()>
- Public Function InvokeIfRequired(Of T1, TR)(control As Control, func As Func(Of T1, TR), arg1 As T1) As TR
- If control.InvokeRequired Then
- Return CType(control.Invoke(func, arg1), TR)
- Else
- Return func.Invoke(arg1)
- End If
- End Function
- ' n parameters can be extrapolated...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement