0

As the title suggest: Which functions of an application are called when it's killed by Windows 10, either by End Task in Task Manager or Terminate it in Settings? Or there's no function called at all and all the threads are killed immediately? I'm working on a program in which lots of data are corrupted/destroyed when user terminates it, I want to reduce the risk of that so I really need your help, unfortunately Google doesn't provide much help in this matter. Thank you.

  • 1
    **Nothing**. Kill means exactly this, the process is terminated and no further code is run, no cleanup, no "last chance" to save, nothing. Killing a process is a last resort when it's not responding, and providing a notification would defeat this purpose. Data loss is a possible consequence, and there is nothing the program can do to prevent it. You may minimize it by saving earlier and often (like the "autosave" feature of Office programs), but ultimately is a program is abruptly terminated any kind of undefined behavior can happen. – Alejandro Jun 16 '21 at 14:59
  • That's what I thought, and early save's my proposed solution, since the save file will be less than 1kB it doesn't seem to affect performance much, yet somehow my lead programmer doesn't really like it and asked me to dig further. :/ – Hiep Le Thanh Jun 16 '21 at 15:31
  • For a 1kb file it'll be pretty much "instant", unless you save several times per second. If you use asyncronous saves, you even leave the UI thread free to keep redrawing and taking user input. The only thing I can think of "digging further" is why the program is killed so frequently to become a problem, or if it crashes often to be a problem – Alejandro Jun 16 '21 at 16:13
  • Nah, it doesn't crash that much, our QA intentionally kill it just for testing and bam, a bug. Thanks, man. – Hiep Le Thanh Jun 17 '21 at 01:15

0 Answers0