c# winform application still running in task manager even though it exited program,cs

Viewed 55

I have winform c# application running on task scheduler (it runs every 2 minutes). I am using application.exit on form_load event after reading a file and insert in database. It works fine but somehow after 2 days of running a scenario occurs where .exe remain running on task manager but program exited successfully since i am logging in text file.

static void Main()
{
    Application.SetHighDpiMode(HighDpiMode.SystemAware);
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);

    Application.Run(new Form1());
    Form1 formObj = new Form1();
    formObj.log(string.Empty, string.Empty, "Application exited successfully");

}

I have this log method in form1.cs It gives Launch request ignored, instance already running Event Id:322 Any help..

1 Answers

A complete exit from the application can be done by using Environment.Exit(0);

Related