Question

I've write a method to perform an operation in various controls at once, this is the Invoke part in VBNET:

If [Control].InvokeRequired Then
    [Control].Invoke(ControlAction, [Control])
Else
    ' ControlAction.DynamicInvoke([Control])
    ControlAction.Method.Invoke(ControlAction, {[Control]})
End If

But really I don't know which is the difference whether if I use DynamicInvoke or Method.Invoke.

Maybe DynamicInvoke is performed asynchronouslly ...or what?.

I've readed the descriptions of both methods but I still confused and it's unclear for me, I don't know what means "late-bound", is a totally strange word for my (and for GoogleTranslator), my english is not good.

Dynamically invokes (late-bound) the method represented by the current delegate

I need a friendly explanation of all this.

Also I would appreciate much more a code example in C# or VBNET demonstrating the differences.

Was it helpful?

Solution

DynamicInvoke isn't performed asynchronously, it's dynamic because your parameters that you pass it to the function checking (and unboxing) in the runtime.Invoke requires exact type of parameters but DynamicInvoke requires an object array which contains your parameters. So you can use DynamicInvoke when you don't know exactly type of the parameter.

Here is full (and better :) explanation about it: Difference Between Invoke and DynamicInvoke

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top