I do not deal with a large number of programs for the Windows GUI, so all this can be well known to people more familiar with WinForms than I am. Unfortunately, I could not find any resources to explain the problems that I encountered today during debugging.
If we call EndInvoke for the async delegate. We will get any exception that occurred during the execution of the re-throw method. The call stack will reflect the original source of the exception.
However, if we do something similar in Windows.Forms.Control, the Control.EndInvoke implementation drops the call stack. This can be observed by a simple test or by viewing the code in Reflector. The relevant code excerpt from EndInvoke is here:
if (entry.exception != null) { throw entry.exception; }
I understand that Begin / EndInvoke on Control and asynchronous delegates are different, but I would expect similar behavior on Control.EndInvoke.
Is there any reason the control does not do what asynchronous input delegates do to keep the original call stack?
Brian rasmussen
source share