|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
System.Diagnostics.Trace.WriteLineJust wonder what the cost of using the API
System.Diagnostics.Trace.WriteLine() is? Infact does anyone know how this works internally - are all calls to the API processed asynchronously by another thread and does it use some form of a queue internally. I guess this uses the win32 api 'OutputDebugString' is this true? Cheers Ollie Riches Hello,
> I guess this uses the win32 api 'OutputDebugString' is this true? actually, it's more complicated.The Trace class uses TraceListeners to which it delegates the messages. By default, the DefaultTraceListener is added, which writes to the Win32 OutputDebugString function. But you can add other (Like textfiles via TextWriterTraceListener) or create eventlog entries (EventLogTraceListener). I personally use the TraceSources nowadays, because you can use them as "categories" which can be enabled and disabled via app.config and you can have more than one in your application. When I write console applications, I don't use Console.Out anymore, but add a TextWriterTraceListener(Console.Out) to the Listener collection... Now, the costs depend on the number of listeners you have and the verbosity configured via the app.config file. You'll really have to measure it... Best regards, Henning Krause |
|||||||||||||||||||||||