首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >帮我分析一下这个callstack来看看我的方法是什么

帮我分析一下这个callstack来看看我的方法是什么
EN

Stack Overflow用户
提问于 2018-12-08 05:54:28
回答 1查看 0关注 0票数 0

好的,所以我有一个非常简单的表单,旁边没有逻辑,由演示者控制。public void Reset()上有一个方法可以将表单重置为初始状态。这应仅由演示者和非常特定的情况(例如活动超时)调用。我遇到了一个问题,虽然在一些边缘情况下(当我模拟我的应用程序丢失数据库连接时)例如,当它不应该被调用时,调用Reset()方法,我无法弄明白。

所以我在Reset()方法中设置了一个跟踪点,并让它打印出callstack。奇怪的是,提出了更多问题。任何人都可以帮我弄清楚Reset()的调用来自哪里?我的callstack在下面。

我应该解释的一件事是DriverInterface2.UI.WinForms.NonInheritingForms.CheckInForm,你可以在callstack中看到它。这是ICheckInForm(相关接口)的一个非常简单的实现,只是创建CheckInForm并委托给它。它只是因为我正在使用城堡windsor和连接从表格继承的类变得非常混乱。无论如何,该方法的全部内容如下:

代码语言:javascript
复制
public void Reset() {_form.Reset();}

这是callstack:

代码语言:javascript
复制
Function: DriverInterface2.UI.WinForms.CheckInForm.Reset(), 
Thread: 0xA96F4 Main Thread, 
Caller: DriverInterface2.UI.WinForms.NonInheritingForms.CheckInForm.Reset, 
Callstack:  DriverInterface2.UI.WinForms.dll!DriverInterface2.UI.WinForms.CheckInForm.Reset
    DriverInterface2.UI.WinForms.dll!DriverInterface2.UI.WinForms.NonInheritingForms.CheckInForm.Reset
    [Native to Managed Transition]
    [Managed to Native Transition]
    mscorlib.dll!System.Delegate.DynamicInvokeImpl
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper
    mscorlib.dll!System.Threading.ExecutionContext.runTryCode
    [Native to Managed Transition]
    [Managed to Native Transition]
    mscorlib.dll!System.Threading.ExecutionContext.RunInternal
    mscorlib.dll!System.Threading.ExecutionContext.Run
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallback
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbacks
    System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc
    System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc
    System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.WndProc
    System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc
    System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage
    System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback
    [Native to Managed Transition]
    [Managed to Native Transition]
    System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop
    System.Windows.Forms.dll!System.Windows.Forms.Application.Run
    DriverInterface2.exe!DriverInterfaceRunner.Program.Main
    [Native to Managed Transition]
    [Managed to Native Transition]
    mscorlib.dll!System.AppDomain.ExecuteAssembly
    Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly
    mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context
    mscorlib.dll!System.Threading.ExecutionContext.Run
    mscorlib.dll!System.Threading.ThreadHelper.ThreadStart
EN

回答 1

Stack Overflow用户

发布于 2018-12-08 15:35:13

在我看来,Windows消息正在编组为.NET事件,并且该事件正在调用您的Reset方法。它是哪个事件,我不知道。如果它不是一个事件,那么它可能是一个异步委托。

如果您从Application.Idle事件中调用Reset方法,则可能会解释它。

导致异步委托被引发的调用(事件处理程序或其他)将不会出现在堆栈中,因为调用是异步的。因此,在系统通过Windows消息泵调度该委托之前,堆栈可能会从该调用中解开。因此,原始调用者不再出现在堆栈中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100000925

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档