Delegate.Invoke

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

Delegate.Invoke([ParamArray parameter1 As Type, parameterN As Type]) As Type

Supported for all project types and targets.

Call the method pointed by the delegate. You must pass the same parameters as the method's ones and, if the method returns a value, you must use the return value as well.

Sample Code

If you defined a delegate as:

Delegate Sub myDelegateMethod(x As Integer, y As Integer, s As String)

then you must use Invoke with the same parameters' type, as in:

Var d As myDelegateMethod
// <— Set d as your code requires
d.Invoke(1, 10, "An example string") // Values are indicative

By contrast, if the Delegate is set to return a value as in:

Delegate Function myDelegateMethod(x As Integer, y As Integer, s As String ) As Boolean

then you must use the value returned by Invoke, as in:

Var d As myDelegateMethod
Var b As Boolean
// <— Set d as your code requires
b = d.Invoke(1, 10, "An example string") // Values are indicative