background
In use Duilib Netease open source Windows application development time, along with increasingly more functionality, you may experience problems not completely withdraw from the process.
The reasons may be:
- Related resources are not properly released
- BUG
- The background thread did not exit
- ……
At this time, we might as well refer to some Android practices, at some entrances, call the system API to force the end of the entire process.
Kill My Self
In NetEase's duilib framework, when the entire application exits, the Cleanup function will be called back. At this time, we only need to end the current process in this function:
// kill myself
HANDLE hself = GetCurrentProcess();
TerminateProcess(hself, 0);
The complete code is as follows:
void MainThread::Cleanup() {
// sdk dispose
cim::cleanup();
ui::GlobalManager::Shutdown();
SetThreadWasQuitProperly(true);
nbase::ThreadManager::UnregisterThread();
HANDLE hself = GetCurrentProcess();
TerminateProcess(hself, 0);
}