0

In my windows application I have a Close button. While click on this it will call a function .

private void btClose_Click(object sender, EventArgs e)
{
  EndFormalities();
}

Is it possible to call the EndFormalities() function, while closing this application through Task manager . Any predefined Events available in Windows.NET ?

John Saunders
  • 159,224
  • 26
  • 237
  • 393
SabarishV
  • 13
  • 3

1 Answers1

0

You can handle the WM_CLOSE message. Once you receive it, you can call your EndFormalities() method. Look at this answer on how to catch it: Handle WM_CLOSE message send to C# Tray App
Also read this one: Can I handle the killing of my windows process through the Task Manager?

Community
  • 1
  • 1
Michalis
  • 543
  • 1
  • 4
  • 10
  • I've tried with "override void WndProc" . But its not even triggered while Ending the application process through Task manager. – SabarishV Nov 04 '14 at 09:25