Mega Code Archive

 
Categories / C# / Development Class
 

Handling Application Events

using System; using System.Threading; using System.Reflection; using System.Windows.Forms;     public class HelloWorldForm : Form {     public HelloWorldForm()     {         Text = "Hello, WindowsForms!";     } }     public class ApplicationEventHandlerClass {         public void OnThreadExit(object sender, EventArgs e)     {         Console.WriteLine("The application's main thread is shutting down.");     } }     public class MainClass {     public static void Main()     {         HelloWorldForm FormObject = new HelloWorldForm();         ApplicationEventHandlerClass AppEvents = new ApplicationEventHandlerClass();             Application.ThreadExit += new EventHandler(AppEvents.OnThreadExit);         Application.Run(FormObject);     } }