Wanzyee Studio
DelegateExtension

Extension methods for System.Delegate. More...

Static Public Member Functions

static object Notify (this Delegate method, params object[] args)
 Invoke the specified delegate event if exists, to notify the receiving handlers. More...
 

Detailed Description

Extension methods for System.Delegate.

Member Function Documentation

static object Notify ( this Delegate  method,
params object[]  args 
)
static

Invoke the specified delegate event if exists, to notify the receiving handlers.

Note, the best is to call the explicit Delegate.Invoke() directly instead of this. Also, you may not need this for callback usage, since it usually has only one handler.

Use this only if you need to read the Unity Profiler hierarchy when deep profiling. While the Profiler indents every single invocation, and quickly make the hierarchy unreadable. This makes a little GC to flatten the delegate, to make the hierarchy not so deep and more readable.

Comparisons:

  • Explicit Delegate.Invoke(): unreadable, fastest and no GC.
  • Dynamic Delegate.DynamicInvoke(): unreadable, very slow.
  • This: readable, slow as dynamic when deep profiling, otherwise just slower than explicit.
Parameters
methodDelegate instance.
argsArguments.
Returns
The result of the last handler.