3
votes
Provide .NET IDisposable support for sections (Method, Task, Thread, ...)
Provide a section object for various section methods (e.g. Method, Task, Thread, …) replacing the Enter/Leave method combination and the try/finally construct for safely leaving an entered section. Then logging can be done easily and safely by a single statement e.g.
using var _ = Si.Section.MethodSection(type);
I have also added (see extra feature requests)
* the type it is called for to have the full reference for the method (e.g. MyClass.MyMethod)
* Leave section also displays the execution time (often interesting and makes no work)
I can provide you with an implementation if you want.
