Re: [twsocket] exception after THttpCli.ReqDone causes double triggerof RequestDone

2012-12-10 Thread brian -
I see. Thanks for the explanation and the workaround :)

On Mon, Dec 10, 2012 at 7:17 AM, Arno Garrels arno.garr...@gmx.de wrote:

 brian - wrote:
  After RequestDone with THttpCli, if there is an -unhandled- exception
  before the code is out of ReqDone stack, RequestDone is triggered
  again.

 [..]

  You will see RequestDone is triggered twice, and external exception
  handlers or delphi's don't trigger at all (e.g madExcept).

 If you want MadExcept handle those exceptions add i.e. these lines

 initialization
   SetIcsThreadLocalFinalBgExceptionHandling(fehAppHandleException);

 This tells ICS to call the global Application's exception handler
 for any unhandled background exception in main thread context rather
 than eat unhandled exceptions.

  I know I can solve this by using try/except on the final code, or
  using BgException (canclose := False),

 Indeed it's best practice to catch and handle all exceptions in the
 event handlers.

  but why is this happening?

 It happens because Abort is called by default on unhandled exceptions
 which in turn calls OnRequestDone() again.

 --
 Arno
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] exception after THttpCli.ReqDone causes double triggerof RequestDone

2012-12-09 Thread Arno Garrels
brian - wrote:
 After RequestDone with THttpCli, if there is an -unhandled- exception
 before the code is out of ReqDone stack, RequestDone is triggered
 again. 

[..]
 
 You will see RequestDone is triggered twice, and external exception
 handlers or delphi's don't trigger at all (e.g madExcept).

If you want MadExcept handle those exceptions add i.e. these lines
 
initialization
  SetIcsThreadLocalFinalBgExceptionHandling(fehAppHandleException);

This tells ICS to call the global Application's exception handler
for any unhandled background exception in main thread context rather 
than eat unhandled exceptions. 

 I know I can solve this by using try/except on the final code, or
 using BgException (canclose := False),

Indeed it's best practice to catch and handle all exceptions in the
event handlers. 

 but why is this happening?

It happens because Abort is called by default on unhandled exceptions
which in turn calls OnRequestDone() again.

-- 
Arno 
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be