Which is faster; using event.Invoke(args)
, or just calling event(args)
. What's the difference? Is one faster or slower than the other; or is it just a matter of preference?
Which is faster; using event.Invoke(args)
, or just calling event(args)
. What's the difference? Is one faster or slower than the other; or is it just a matter of preference?
Writing someDelegate(...)
is a compiler shorthand for someDelegate.Invoke(...)
.
They both compile to the same IL—a callvirt
instruction to that delegate type's Invoke
method.
The Invoke
method is generated by the compiler for each concrete delegate type.
By contrast, the DynamicInvoke
method, defined on the base Delegate
type, uses reflection to call the delegate and is slow.