首先我的代码如何执行,
// Form1.h
1. A delegate and a method are implemented to update a textbox.
2. Managed delegate is marshaled to unmanaged and passed to native C++ class.
2. On button click event, a background worker is started.
3. The background worker calls a method of "Class1" (native C++).
// Class1.h
1. Method called in "Form1.h" runs a loop from 1 to 100. For every run, it calls method of "Class2" (native C++).
// Class2.h
1. Method called in "Class1.h" makes a callback to the delegate in "Form1.h" to update the textbox.
我能够成功构建调试和发布.exe文件。当我按下表单上的按钮时,两个构建都运行良好并且文本框已更新。但是,当我尝试使用调试器运行代码时,代码执行奇怪地停止在" Form1.h"中实现的文本框更新方法中。在循环中第一次运行" Class1"方法。这意味着后台工作程序已启动,方法是" Class1" (循环首次运行)和" Class2"成功执行。问题出现在" Class2"的方法之后。回复" Form1"并且已成功调用update方法但未执行。
使用调试器执行代码的奇怪行为可能是什么原因?