Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I invoke a Delegate faster than by using DynamicInvoke?

Currently I useDynamicInvokewhich is very slow. Still using theDelegatetype how can I directly invoke the Delegate without late-binding/theDynamicInvoke?

Delegate _method;    
_method.DynamicInvoke(_args);

Thanks.

like image 645
DayTwo Avatar asked Oct 11 '10 13:10

DayTwo


1 Answers

The open source framework Impromptu-Inteface adds an extension method to Delegate called FastDynamicInvoke that runs a little over 20 times faster than DynamicInvoke by using the DLR instead of reflection.

using ImpromptuInterface

...

_method.FastDynamicInvoke(_args);
like image 200
jbtule Avatar answered Sep 29 '22 17:09

jbtule