views:

751

answers:

3

Simple question i belive, is

outputdebugstring(pansichar(''));

Thread safe?

I/We have been using it in threads for debugging, and i never occurred to me if i should be doing it a different way.

(delphi7)

+6  A: 

Don't worry, it is.

regards,

Lieven

Lieven
Thank you, just what i wanted to hear :)
Christopher Chase
+17  A: 

Well, not that it isn't true, it is, but just so that you don't have to just take Lieven word for it:

Passing of data between the application and the debugger is done via a 4kbyte chunk of shared memory, with a Mutex and two Event objects protecting access to it. These are the four kernel objects involved.

Understanding Win32 OutputDebugString is an excellent article on the matter.

Jorge Córdoba
I knew it was threadsafe because I once had to look it up myself. I didn't know the entire story behind it anymore though. Thanks for clarifying it.
Lieven
+1  A: 

I've had trouble once, though, with strings in an ISAPI DLL. For some odd reason the IsMultiThread boolean defined in System.pas was not set! Causing weird AccessViolations, once the thread was running more than one thread... A simple "IsMultiThread:=true;" in a unit initialization fixed it.