Question

While using dotTrace profiler I am getting a lots of calls to NamespaceName.ClassName.ctor>b__11 (When I used Equatec profiler on my application I got similar results with the mysterious function being called NamespaceName.ClassName.<ctor>b__11 ). I first assumed that it is the constructor of the ClassName but the break point inside of the constructor of ClassName was only hit once. I am assuming this is auto generated function and if it is how can I find where it gets called? What relation does it have to the constructor of ClassName if constructor only gets called once?

Était-ce utile?

La solution

It's probably a lambda declared in the constructor. Did you subscribe to an event in the constructor using the => syntax, or something else that will get called frequently?

When you use a lambda, the C# compiler turns that into a private method, and uses a delegate to that method. (And other fancy tricks if you're doing variable capture.)

Looking at other classes in Reflector, it looks like the C# compiler simply numbers each lambda when it turns them into methods, with the naming convention you've noticed, <methodName>b__<number>, just numbering each one as it goes.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top