Prevent the application from exiting when the Console is closed
问题 I use AllocConsole() to open a Console in a winform application. How can I prevent the application from exiting when the Console is closed? EDIT The update of completionpercentage from time to time is what I want to show in console void bkpDBFull_PercentComplete(object sender, PercentCompleteEventArgs e) { AllocConsole(); Console.Clear(); Console.WriteLine("Percent completed: {0}%.", e.Percent); } I tried the richtextBox as the alternative s =(e.Percent.ToString()); richTextBox1.Clear();