> What Chris describes is my experience. I use it alot for throwing
stuff to console that helps me debug. There is a noticable performance
hit though, and I wonder, if the console is not enabled, and a
Console.WriteLine call is made, what happens? Is there some sort of
buffer or resource that the text still writes to? I've never tested
the performance of writing to console when there is no console, as I
only do this when compiled as DEBUG, using conditional compilation
statements.
Maybe System.Windows.Forms.Application.MessageLoop will help decide the
issue at runtime. It returns true if there a message loop is running on the
current thread. So, if your app is single threaded, then it should tell the
difference between a console app and a windows app. Multi-threading
complicates things - a worker thread in a windows app cant effectively use
it. Also, I don't know what it does in other settings, eg a service.
The compiler /target option is what really decides the issue. So the answer
to the original question is yes - the compiler knows about /target. But I
couldn't find out how to access it or an equivalent at compile time (eg via
#if) or run time.