How To Dynamically Invoke Methods Quickly

added by tdupont
10/2/2016 4:27:41 PM

1 Kicks, 201 Views

In my previous blog post, I talked about Optimizing Dynamic Method Invokes in .NET. In this post, we will use that information to create a static helper method that is twice as fast as MethodInfo.Invoke. Basically, we create and cache a delegate in a concurrent dictionary, and then cast both it and it's arguments to dynamics and invoke them directly.