我需要知道函数何时被调用,函数何时结束。否则,每次">StackTrace.FrameCount"更改时,我都需要检测。
我的想法是将我的函数插入"StackTrace.FrameCount"的Setter中,并重定向到FrameCount的基本函数,但。。。问题是,"StackTrace.FrameCount"只有一个GETTER。
//
// Zusammenfassung:
// Gets the number of frames in the stack trace.
//
// Rückgabewerte:
// The number of frames in the stack trace.
public virtual int FrameCount { get; }
是否有可能创建PropertyChangedEventHandler或其他东西来管理此问题?
非常感谢!:(
Thomas
您可能正在寻找某种AOP来拦截方法进入和退出"事件"。例如,一种简单的方法是MethodBoundaryspect。Fody,它使您能够编写一个自定义属性,该属性公开了三种不同的拦截方法,OnEntry
、OnExit
和OnException
。要测量方法的性能,您可以简单地在OnEntry
中启动秒表,然后在OnExit
中停止并显示经过的时间。