I would like to be able to detach my program from the console much like wget -b
. A code fragment might look like
static void Main(string[] args)
{
var settings = new Settings(args);
if (settings.Background)
{
/*Tell the user what's going on.*/
System.Console.WriteLine("Detatching from console. The program will still be running.");
System.Console.Out.Close();
}
/*do work then exit.*/
}
But System.Console.Out.Close();
doesn't do the right thing.
To clarify, the "right thing" is, when running this program from the console, the prompt should re-appear. Or, when running this program from explorer.exe
, the console window should close.
Please let me know if I am not being clear.
start
on the command line. – Turtledovewget -b
and get the behaviour I'm wanting. I'm not wanting the program to be headless from the start. I would like, for instance, for the program to print a line to console, then detach, giving the user the command interpreter again. – Morionwget -b
on Linux? Or in Cygwin? You do realize that linux shells (including bash on cygwin) and windows shell are completely different animals, right? – Accommodative