I have an application that opens like this: (Program.cs)
Main MainForm = new Main();
Application.Run();
if the user does not specify /hide option, then the program shows like this:
(Main.cs)
internal Main()
{
InitializeComponent();
this.Show();
}
Sometime, the program needs to close immediatly if a file does not exist. So I close it like this: (Main.cs)
private void MainLoad(object sender, EventArgs e)
{
if (!File.exist("FilePath")
this.Close();
}
on FormClosed, I have this:
Application.ExitThread();
This destoy’s almost everything from the application, including the Taskbar icon. However, on Visual Studio, the program is still “Running” until I click “Stop Debugging”.
Anyone has any idea why this is happening ?
Objective: I want to start the program minimized(No Flash screen shown) if the user specify /hide argument.
The program will automatically close if a certain file is not found.
Instead of
this.Close();, try usingEnvironment.Exit();