Ending the appliation reliably

A

Adam Honek

Hi all,

Is it safe to use application.exit or application.exitthread to end a
program in .NET?

If we didn't use the forms designer then there isn't any generated code to
dispose of controls upon termination, would the above clear any resources
up?

Also, what if we have a multi-thread app?

Perhaps it's better to use the API? Maybe TerminateProcess???

Adam
 
C

Cor Ligthert [MVP]

Adam,

The best Net programs are withouth any API. When you had looked at the
beginning in this newsgroup, it were all answers with API's. Given by VB6
guys/girls. Now you don't see them almost not anymore (they can be needed in
some cases)

In fact you don't have to set anything to close your application, the user
does it with pushing the cross. While mostly the me.close from the mainform
does it if you want to forsce this.

The settup setting in your project properties tells how you start your
project. This setting is a little bit different for the version 2002/2003
and 2005. Easier but more confusing in the first one.

In a sub main class, the logic goes normally just to an end.

One of the main points of managed code is to release all used managed
recourses.

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top