Does e.CloseReason work for you?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Protected Overrides Sub OnFormClosing(ByVal e As
System.Windows.Forms.FormClosingEventArgs)

MyBase.OnFormClosing(e)

Console.WriteLine(e.CloseReason.ToString )





always writes

UserClosing

No matter if I'm closing the form, exiting the app, shutting down windows or
using the Task Manager to shut down the app.



Does e.CloseReason work for you?





Thanks








.


Quantcast