System.Windows.Forms.Application.ApplicationExit Event

Occurs when the application is about to shut down.

Syntax

public static event EventHandler ApplicationExit

Remarks

You must attach the event handlers to the Application.Exit event to perform unhandled, required tasks before the application stops running. You can close files opened by this application, or dispose of objects that garbage collection did not reclaim.

Because this is a static event, you must detach any event handlers attached to this event in the Application.ApplicationExit event handler itself. If you do not detach these handlers, they will remain attached to the event and continue to consume memory.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0