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

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -