Public Sub InvokeIfRequired(ByVal method As Action)
If Me.InvokeRequired = True Then '"Me" being the current form.
Me.Invoke(Sub() InvokeIfRequired(method)) 'Invoke this method to make it thread-safe.
Else
method.Invoke() 'Execute the specified method.
End If
End Sub
InvokeIfRequired(AddressOf HideWindow) 'Va appeller la fonction HideWindow
InvokeIfRequired(Sub() Me.Visible = True) 'Va rendre la fenêtre visible
InvokeIfRequired(Sub() Me.WindowState = FormWindowState.Normal) ' Va régler le paramètre Me.WindowState sur Normal