I'm developing a `console` application that is supposed to run under `WinCE 6.0` and `WinCE 7.0`. I'm using `C#`, `Compact Framework 2.0` for different compatibility reasons.

My application is started by an external runtime called `TwinCAT` (from Beckhoff). Within this application, my teammate used a function block called `nt_startProcess` (documentation [here](http://infosys.beckhoff.com/english.php?content=../content/1033/tcplclibutilities/html/tcplclibutilities_nt_startprocess.htm&id)) that is in charge of starting my application on demand.

**My problem - Two different behaviors depending on the OS :**

1. When started manually (without TwinCAT) from a `cmd` line :

My application behaves properly on both systems. It means that, the applications starts, displays "Hello World" and then returns to the `cmd` line.
2. When started from TwinCAT :

a) On `WinCE 6.0`, I can see a cmd line opening, displaying "Hello World" and shutting itself right after. Perfect behavior to me.

b) On `WinCE 7.0`, I can see a cmd line opening, displaying "Hello World" but it remains open forever. **This is my problem!**

**Code snippet :** 

```
using System;
using System.Collections.Generic;
using System.Text;

namespace MyBasicExample
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World");
    }
  }
}

```

**Compilation information**

In Visual Studio 2008, within the Project compilation's properties :

* Plateform target : Any CPU

**Additionnal note :** 

Please note that the computer who is running WinCE 6.0 is using a i486 processor while the one running WinCE 7.0 is using a Freescale ArmCortex process.

*WinCE 6.0 :*  

![WinCE 6.0](https://i.stack.imgur.com/6BVcJ.jpg)

*WinCE 7.0 :*  

![WinCE 7.0](https://i.stack.imgur.com/cLxAU.jpg)

**What I tried :**

1) Using `return 0;` at the end of application.

Doesn't change anything on WinCE 7.0.

2) Using `Environment.Exit(0);`

Is not available in Compact Framework 2.0.

3) Using the property : `IsBackground`

Snippet : 

```
// ... Same snippet as above except for the next line...
Thread.CurrentThread.IsBackground = true;
Console.WriteLine("Hello World");
// ...

```

4) From TwinCAT, calling a batch file (which calls my exe) instead of my exe.

Doesn't work with TwinCAT. I get an error of type "General Sub-Windows error".

5) Tested with the Compact Framework 3.5.

Same behavior.

6) Tested with another CX computer (model 2020) using Windows CE 7.0 and another processor architecture (Intel Pentium III Xeon Model A).

Same behavior.