[Mono-dev] how to fix TextWriterTraceListener disposal problem

Jonathan Pryor jonpryor at vt.edu
Thu Apr 14 17:31:02 EDT 2011


On Apr 13, 2011, at 4:06 AM, Atsushi Eno wrote:
> Do you have any ideas how to solve this problem?

Is it actually a problem? :-)

The reason I ask is that I vaguely recall testing the same behavior under .NET at the time (circa 2002?), and .NET behaved the same way -- the stream was not flushed.

Furthermore, the only solution I know of to fix this (or knew of circa 2002), was to use a finalizer on TraceListener, which MSDN states TraceListener does not provide.

Consequently, I believe that TraceListener is not supposed to flush the stream at all, and if you really want the stream to be flushed you should set Trace.AutoFlush=true, either programmatically or via .config file; MSDN kindly provides the .config file snippet here:

	http://msdn.microsoft.com/en-us/library/system.diagnostics.tracelistener.aspx

 - Jon



More information about the Mono-devel-list mailing list