Handling Application Events : Application Event : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Application Event »

 

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 OnApplicationExit(object sender, EventArgs e)
    {
        try
        {
            Console.WriteLine("The application is shutting down.");
        }
        catch(NotSupportedException)
        {
        }
    }
}
   
public class MainClass
{
    public static void Main()
    {
        HelloWorldForm FormObject = new HelloWorldForm();
        ApplicationEventHandlerClass AppEvents = new ApplicationEventHandlerClass();
   
        Application.ApplicationExit += new EventHandler(AppEvents.OnApplicationExit);
        Application.Run(FormObject);
    }
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Application Event