Alex Rivera | Logout

c# console wont close after program ends

Asked 2013-03-15T05:49:50.893
11

I have c# application that I am running, and then in some point application throws an error which is then catched, then app should end. And it ends, but console windows stays open...

I even checked in windows task manager, under applications tab, there is listed my console, but when I click go to process, there is no process of that application.

Thats weird... Application ended, process ended, but console stays on? How can I kill that console?

Edit: my code:

static class Program
    {
        static void Main()
        {
            try
            {
                //bunch of static methods from other static classes are being invoked

                Setup.Driver.Close();//another static method
            }
            catch (Exception)
            {
                Setup.Driver.Close();
            }
        }
    }

Second edit: Note: Process.Getprocess().Kill(), Application.Exit(), Environment.Exit() are not working for me, in windows task manager, there is no process left to kill, only console stays open!

Edit
Report

1 Answer

6

Environment.Exit and Application.Exit

Environment.Exit() is cleaner.

http://geekswithblogs.net/mtreadwell/archive/2004/06/06/6123.aspx

answered 2013-03-15T05:55:40.457

Your Answer