3

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 Answers1

4

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.

ctacke
  • 66,480
  • 18
  • 94
  • 155
  • Have you ever make a try with `Windows Embeeded 7` ? I run your sample code with CF 2, the form is closed, but the process doesn't end. If I launch my application from cmd, I have to `ctrl+C` to end the process. I think it is the same problem than [this post](http://stackoverflow.com/questions/31671893/console-application-not-closing) – stephanejulien Aug 06 '15 at 12:57