Someone asked quite a similar question here C# Application.Run without Form
but the checked answer doesn't suit me.
What I'd like to do is this :
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
ObjController objController = new ObjController();
Application.Run();
Application.Exit();
}
with
class ObjController
{
Form1 form1 = new Form1();
public Form1 showObj()
{
form1.Show();
return new Form1();
}
}
But when closing the form Application.Exit()
in main()
doesn't seem to execute. Why ? What can I do instead ?