Question

I'm running Windows CE 6.0 on an ARM processor device using .NET CF 2.0 SP2 with an application written in C#.

I'm experiencing a problem where my application continues to run after it has closed. The application opens a connection with something connected to the device and doesn't release it until properly closed. Because of this, I cannot reopen and use the application while it continues to run and I can't run other applications which wish to use the attached device either.

I have tried to run Application.Exit() and all of my threads have the IsBackground property set to true but this doesn't work. After closing the application I can use a task manager and see that the process continues to run.

I'd normally use Environment.Exit() but this is not available in CF, unfortunately.

Is there any of methods I can try and use or causes that would be making this happen?

Thanks.

Was it helpful?

Solution

You could try something like this:

Process thisProcess = Process.GetCurrentProcess();
thisProcess.Kill();

And see what happens. It's obviously not ideal to closing a application, but it might work as a last resort, especially if you're handling the saving and discarding of data manually prior to that anyway.

OTHER TIPS

For anyone still struggling with this:

I found the problem was that with Windows CE / WEHH / .NET Compact, applications don't exit on pressing the X button on a form, they are only minimized (meaning the closing event doesn't get called).

As per one of the answers on this page, the close button can be changed to actually exit the application by setting the form property 'MinimizeBox' to false.

this.MinimizeBox = false;

This will change the X button to an OK button, and will exit the application completely.

May be this can Help. Set Thread's Background Property to false before calling Application.exit();

private void BtnExit_Click(object sender, EventArgs e)
{
  Thread1.IsBackground = false;
  Thread2.IsBackground = false;

  Application.exit();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top