How do I guarantee fast shutdown of my win32 app?

前端 未结 11 1853
夕颜
夕颜 2020-12-03 19:13

I\'ve got a C++ Win32 application that has a number of threads that might be busy doing IO (HTTP calls, etc) when the user wants to shutdown the application. Currently, I p

11条回答
  •  佛祖请我去吃肉
    2020-12-03 19:40

    Instruct the user to unplug the computer. Short of that, you have to abandon your asynchronous activities to the wind. Or is that HWIND? I can never remember in C++. Of course, you could take the middle road and quickly note in a text file or reg key what action was abandoned so that the next time the program runs it can take up that action again automatically or ask the user if they want to do so. Depending on what data you lose when you abandon the asynch action, you may not be able to do that. If you're interacting with the user, you may want to consider a dialog or some UI interaction that explains why its taking so long.

    Personally, I prefer the instruction to the user to just unplug the computer. :)

提交回复
热议问题