c# - Ways to kill a running program and how to trap them? -


we have different ways kill running c# program.

  1. ctrl + c;
  2. task bar right click icon, select 'close' on popup;
  3. task manager, select executable name , click end process;
  4. console window, use kill command;

maybe more.

what asking here how handle them in c# program guarantee c# program exit gracefully when possible. know how trap ctrl + c, don't others. can me? thanks,

the best guarantee have @ code being run @ exit statement.

note though program have run in try block when use mechanism.

i believe time block inside finally not executed at:

  • a stackoverflowexception;

  • corrupted state exceptions (from .net 4);

  • forceful termination through task manager (an unmanaged process kill);

  • crash of entire system (removing power cable e.g.).

see keep code running reliability features of .net framework in depth analysis.


Comments

Popular posts from this blog

SAP Web Service from .NET via WCF -

Optimized Line drawing in QT -

datetime - str to time in python -