Main Site Documentation

The thread '<No Name>' (0x6) has exited with code 0 (0x0)


#1

In you main app if you do nothing you will get the
The thread ‘’ has exited with code 0 (0x0).

public static void main()
{

}

Being to to VS, C# and .netmf that sound like to me it exited the main method.
if this is so, where does it then go ?


#2

Embedded systems are meant to operate forever.

I would consider where it goes if you exit to be undefined.


#3

But even when you start a new project and you get this default code. It gives you that exited message.
Yet its in a while loop. So what did it exit from and where did it go ?


public static void Main()
        {
            // Blink board LED

            bool ledState = false;

            OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);

            while (true)
            {
                // Sleep for 500 milliseconds
                Thread.Sleep(500);

                // toggle LED state
                ledState = !ledState;
                led.Write(ledState);
            }
        }


#4

.NET does funny things behind the scenes.

The framework may have started a thread to assist with initialization of your program. Once you program is started it can die.

On full .NET I often see threads terminating at unexpected times. I gave up worrying about it a long time ago. :slight_smile:

The answer is in the open source .NET MF code.