System.Console in WindowsApplication

  • Thread starter Thread starter Stefano Meier
  • Start date Start date
S

Stefano Meier

If in a WindowsApplication in the static main method I have something like:

System.Console.WriteLine("Starting Application ..:");

and I start this WindowsApplication from a console I won't recive the
"Starting Application ..:" message. Why?
 
hi stefano,

do you have Console.Read() or Console.ReadLine() after your
Console.WriteLine()?
if not, you should put one because WriteLine() alone will automatically exit
the application.
 
Stefano Meier said:
If in a WindowsApplication in the static main method I have something like:

System.Console.WriteLine("Starting Application ..:");

and I start this WindowsApplication from a console I won't recive the
"Starting Application ..:" message. Why?

Because a Windows Application detaches itself from the console that
starts it (if any) as soon as it starts.
 
Hi Stefano,

I suppose the reason is that a Windows GUI application does not have a
console allocated to it. With Windows API, one could either allocate a new
console or use the parent application's console (not sure about that). With
..NET, it seems to be no easy way to allocate a console, but I may be wrong.
 
Back
Top