Hello Wu,

we avoided the problem by setting

  Application.UpdateFormatSettings := false;

which means that the format settings never get refreshed after
application launch. Hence, the settings are threadsafe as they never
change.

Saturday, May 26, 2007, 5:02:17 AM, you wrote:

WA> Hi, I am new to this maillist. I have a small (but anonying) problem about
WA> raising exception in Delphi, which I can't find a good answer anywhere. I
WA> hope someone could shed me some light on it.

WA> My question is: "Is raising Exception threadsafe in Delphi?" To be clear,
WA> it is not about the "raising" part, but the "Exception" part.

WA> The "Exception" class in SysUtils unit has a serie of constructors 
WA> Create*Fmt*() that combines "Format" functionality into the constructor.
WA> When I examine its source I found out those constructors all use the 
WA> "Format(Format, Args)" routine. However, the Delphi documentation clearly
WA> stated that the "Format(Format, Args)" routine is NOT threadsafe. So, I
WA> think it also implies that the Exception class constructors that use them
WA> are NOT threadsafe, which means, raising an exception using the Create*Fmt*
WA> constructor is NOT threadsafe!(?!)

WA> After discovering this problem, I coded my own "threadsafe" version 
WA> exception class which uses the threadsafe "Format(Format, Args, 
WA> FmtSettings)" routine, feeding it a per-thread copy of FormatSettings.

WA> Yes, you can call me paranoid, because even I have the same feeling. So I
WA> really want to know whether my suspect is true or I am practising something
WA> that is not necessary...

WA> ------
WA> .dlrow eht htiw thgir s'lla ,nevaeh sih ni si doG

WA> _________________________________________________________________
WA> 与联机的朋友进行交流,请使用  Live Messenger; 
WA> http://get.live.com/messenger/overview 


WA> 
---------------------------------------------------------------------------------------
WA> Orange vous informe que cet  e-mail a ete controle par l'anti-virus mail.
WA> Aucun virus connu a ce jour par nos services n'a ete detecte.




-- 
Best regards,
 Stephen                            mailto:[EMAIL PROTECTED]


_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to