#region Using directives using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.IO; using System.Windows.Forms; #endregion namespace ApplicationsSample { partial class MainForm : Form { public MainForm() { InitializeComponent(); } private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { // // Close the application when the main form goes away // // Only for use when Application.Run is called without // // any arguments // Application.Exit(); //throw new Exception("Unhandled exception occurred."); } private void applicationExitButton_Click(object sender, EventArgs e) { Debug.WriteLine("Calling Application.Exit()"); Application.Exit(); } private void applicationThreadExitButton_Click(object sender, EventArgs e) { Debug.WriteLine("Calling Application.ExitThread()"); Application.ExitThread(); } private void throwExceptionButton_Click(object sender, EventArgs e) { Debug.WriteLine("Throwing an exception"); throw new FileLoadException(); } } }