Discord Server Twitter Donation Youtube
3way

(Who am I?)




Joined: 09-21-2017
D.O.B: 09-11-2001 (17 years old)
Local Time: 06-25-2019 at 10:59 PM

Additional Info About 3way
Location: Who knows?
Bio: Message me on discord if you need help with something C# :)
3way#8063
Sex: Male

3way's Most Liked Post
Post Subject Numbers of Likes
Proper way to exit your C# applications 1
Thread Subject Forum Name
Proper way to exit your C# applications C#
Post Message
The proper method would be Application.Exit()

According to the documentation, it terminates all message loops and closes all windows thus giving your forms the possibility to execute their cleanup code (in Form.OnClose etc).

Environment.Exit
would just kill the process. If some form has e.g. unsaved changes it would not have any chances to ask the user if he wants to save them. Also resources (database connections etc.) could not be released properly, files might not be flushed etc.

Form.Close just does what it says: it closes a form. If you have other forms opened (perhaps not now but in some future version of your application), the application will not terminate.



Keep in mind that if you use multithreading, Application.Exit() will not terminate your threads (and thus the application will keep working in the background, even if the GUI is terminated). Therefore you must take measures to kill your threads, either in the main function or OnClose event of your main form.

Comments (Total )

 
Offline
Joined: 09-21-2017
Last Visit: 11-14-2017, 03:08 PM
Total Posts: 9 (0.01 posts per day | 0.51 percent of total posts)
(Find All Posts)
Total Threads: 4 (0.01 threads per day | 0.46 percent of total threads)
(Find All Threads)
Time Spent Online: 12 Hours, 47 Minutes, 45 Seconds
Referred By: Mr.Kurd
Members Referred: 0
Total Likes Received: 3 (0 per day | 3.61 percent of total 83)
(Find All Threads Liked ForFind All Posts Liked For)
Comments 0 (0 sent | 0 received)

Buddy List (Total 0)
3way hasn't made any friends yet.

Last Visitors
Not visited yet.
Total profile views : 2