A long time ago, Thomas Mueller (dummzeuch) – Google+ reminded [WayBack] me of this which I required a short while ago:
You can use
AcquireExceptionObject()
:AcquireExceptionObject returns a pointer to the current exception object and prevents the exception object from being deallocated when the current exception handler exits.
Then you can send the pointer to another thread and if you raise it there it will be freed for you, otherwise you must call
ReleaseExceptionObject()
to free it.
After the answer by Remy Lebeau [WayBack] and Remko [WayBack] is a comment [WayBack] by mghie [WayBack] that mentions AsyncCalls.pas that now is available on GitHub [WayBack].
If you have a very old (version <= 5) Delphi or just want to look at how AcquireExceptionObject
[WayBack] looks like just look at a similar implementation there [WayBack]. Note that instead of the ReleaseExceptionObject
[WayBack] call, AsyncCalls re-raises the exception [WayBack].
–jeroen
Filed under: Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2007, Delphi 2009, Delphi 2010, Delphi 5, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development
