In c++ there is a function called atexit where you can register functions which should be run when the system exits. Are there any similar events in C#?
UPDATE:
The AppDomain.ProcessExit doesn't seem to catch Ctrl-C or Ctrl-Break. Anyone knows anything about that?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…