さて、プレゼンターによって制御される、ロジックがほとんどない非常に単純なフォームがあります。フォームを初期状態にリセットするメソッド public void Reset() があります。これは、プレゼンターのみが、非常に特殊なケース (アクティビティ タイムアウトなど) で呼び出す必要があります。問題が発生していますが、いくつかのエッジケース (たとえば、アプリケーションがデータベース接続を失うことをシミュレートしている場合) で、Reset() メソッドが呼び出されるべきではないときに呼び出され、何が原因であるかを理解できません。 .
そこで、Reset() メソッドにトレースポイントを設定し、コールスタックを出力させました。奇妙なことに、さらに多くの疑問が生じました。Reset() への呼び出しがどこから来ているのかを理解するのを手伝ってくれる人はいますか? 私のコールスタックは以下です。
説明しなければならないことの 1 つは、コールスタックで確認できる DriverInterface2.UI.WinForms.NonInheritingForms.CheckInForm です。これは、ICheckInForm (関連するインターフェイス) の非常に単純な実装であり、単純に CheckInForm を作成し、それに委任します。これは、Castle Windsor を使用していて、Form から継承するクラスを配線するのが面倒だからです。いずれにせよ、そのメソッドの完全な内容は次のとおりです。
public void Reset() {_form.Reset();}
そして、コールスタックは次のとおりです。
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