مساعدتي تحليل هذا callstack لرؤية ماذا يكون تدعو لي طريقة

StackOverflow https://stackoverflow.com/questions/378691

  •  22-08-2019
  •  | 
  •  

سؤال

وطيب، وذلك لدي نموذج بسيط جدا مع بجانب أي منطق في أن تسيطر عليها من قبل مقدم. هناك طريقة عليه إعادة تعيين باطلة العامة () أن يعيد النموذج إلى حالته الأولية. ينبغي أن يسمى هذا فقط من قبل مقدم وفي حالات محددة جدا (مثل مهلة النشاط). أنا على التوالي في مشكلة على الرغم حيث في بعض الحالات حافة (أنا عند محاكاة طلبي فقدان اتصال قاعدة البيانات على سبيل المثال) إعادة تعيين () هو الحصول على استدعاء الأسلوب عندما لا ينبغي أن يكون، وأنا لا يمكن معرفة من قبل ما .

وهكذا أقوم بإعداد tracepoint في طريقة إعادة تعيين () ويكون ذلك طباعة callstack. والغريب أن أثار المزيد من التساؤلات. يمكن لأي شخص أن يساعدني معرفة أين الدعوة إلى إعادة تعيين () قادم من؟ بلدي callstack أدناه.

وشيء واحد أود أن أشرح هو DriverInterface2.UI.WinForms.NonInheritingForms.CheckInForm التي تستطيع أن ترى في callstack. هذا هو تطبيق بسيط جدا من ICheckInForm (واجهة relavant) وببساطة يخلق CheckInForm والوفود إليه. ومن هناك فقط لأنني أستخدمه قلعة وندسور والأسلاك حتى الفئات التي ترث من نموذج يحصل فوضى فظيعة. في أي حال، فإن كامل محتويات تلك الطريقة هي هذه:

public void Reset() {_form.Reset();}

وهنا في callstack:

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
هل كانت مفيدة؟

المحلول

ويبدو لي وكأنه يجري تنظيمها رسالة Windows إلى الحدث. NET و هذا الحدث وتدعو طريقة إعادة تعيين الخاص بك. الذي حدث هو، أنا لا أعرف. إذا لم يكن هذا الحدث، فلا يمكن أن يكون مندوب غير متزامن.

إذا كنت تسمى طريقة إعادة تعيين من حدث Application.Idle، التي قد تفسر ذلك.

وهذه الدعوة التي قادت مندوب غير متزامن التي ستطرح (معالج الحدث أو غير ذلك) لن تظهر في كومة كما كانت المكالمة غير متزامن. لذلك، المكدس قد تنهار من تلك الدعوة قبل النظام ارسلت ما أن مندوب عن طريق مضخة رسالة ويندوز. ولذلك، فإن المتصل الأصلي لم يعد موجودا في المكدس.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top