C # console does not close after program termination

I have a C # application that I launch, and then at some point the application throws an error, which then gets caught, then the application should end. And it ends, but the console windows remain open ...

I even checked in windows task manager, under the tab applications, my console is displayed there, but when I click go to process, the process of this application is missing.

Thats weird ... The application has ended, the process has ended, but the console remains on? How can I kill this 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 () do not work for me, in the Windows task manager there is no process left to kill, only the console remains open!

+6
6

Environment.Exit Application.Exit

Environment.Exit() .

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

+5
Environment.Exit(0);

this.Close();

, Exit:

using System.Diagnostics;

ProcessThreadCollection currentThreads = Process.GetCurrentProcess().Threads;

foreach (var thread in currentThreads)
{
   thread.Interupt(); // If thread is waiting, stop waiting

   // or

   thread.Abort(); // Terminate thread immediately 

  // or

   thread.IsBackGround = true;
}
+5

,

- , Visual Studio , / ?

, " ENTER ..." ( ).

, *.vshost? , "" Visual Studio "" ; *.vshost Visual Studio.

,

+2

, , , .

.

, , .

+2
Environment.Exit();

?

0

. , Driver.Close(); , chromedriver . Driver.Quit(); , , return; .

!

0

All Articles