lundi 23 février 2015

Why is destructor for a form called twice?

This code with entry point calls form's destructor twice.



void Main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
MyApp::MyForm form;
Application::Run(%form);
}


I have changed it to



void Main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew MyApp::MyForm);
}


The second version calls destructor one time only.


Why initially was it called twice?


Aucun commentaire:

Enregistrer un commentaire