问题
How do I go about force-closing an application on Windows CE 5.0, using C#? I've already tried Application.Exit()
but this doesn't always kill all currently running threads.
I'd normally use Environment.Exit()
but this is not available in CF, unfortunately.
回答1:
It depends on the version of the CF you're using. Application.Exit
is the correct mechanism to exit the app, but your threads have to be handled as well. In CF 2.0 and 3.5, set the IsBackground
property to true
on all created threads (just do it at creation time). On CF 1.0, you have to manually add a flag into the containing class that the thread proc looks at periodically to know if it should exit.
来源:https://stackoverflow.com/questions/15967894/force-close-windows-ce-5-app-using-c-sharp