On Sun, 02 Nov 2008 17:50:04 -0700, puzzlecracker <ir*********@gmail.com>
wrote:
I've just discovered DynamicInvoke methods while reading Jon's
threading article. And my question is how it's different from a
regular invoke method?
[...]
Perhaps it parses arguments from object[] one by one, converting to
appropriate type, and passes them to delegate -- I am just guessing.
I don't think it does. I believe that the arguments do need to match the
target method's declared types.
I admit, I have little first-hand information about DynamicInvoke(). But,
my understanding is that it's useful when you've got a delegate for which
the signature isn't known at compile time. It allows you to build the
argument list dynamically and pass it without matching a specific
signature.
Note that the Invoke() method is not part of the Delegate class per se,
but is generated for each delegate type by the compiler. It's done that
way so that the Invoke() method _does_ have a specific signature that
needs to be matched at compile-time.
In other words, DynamicInvoke() provides for late-bound, dynamic method
invocations, while the Invoke() method provides for statically typed,
early-bound invocations.
Pete