Reputation: 10463
Imagine you have class A which has code which runs as method M. And there is class B which needs to signal A that it is time to run M.
Normally you will fire an event. However there are few ways to do it. Fire an event, call Action or call M as public method. ie:
b.OnMEvent(this, null);
b.MAction();
a.M();
Is there any chance that any of these (or other) ways to call other calss method be inlined in run-time?
Is it possible to achieve in .NET 4.5 with aggressive inlining?
Upvotes: 1
Views: 201
Reputation: 171178
The current version of the .NET JIT does not inline delegate calls. Events are using delegates as a mechanism for invocation so event invocations won't be inlined either.
Inlining a delegate is hard because the target is not necessarily known at compile time. There are mitigating techniques but the current JIT does not implement any of them.
Delegate invocations are fast enough in most cases, though.
Upvotes: 2