G400-D MFConsole projects Debug message

Because I do not know all of the newances for using the G400 I need to ask a simple question.

When using a MFConsole project, I add:


 public static void Main()
 {
      // Do whatever

      Thread.Sleep(-1);
 }

I 'think in general Thread.Sleep(-1); is frowned upon?

Anyway, If I do not add the Thread Sleep(-1) I receive the message

Waiting for debug commands…

It pops up through whatever image I have showing in the LCD Display.

Is using the Thread Sleep forever OK or is there a way to suppress the Debug message once my program starts?

Thanks!

You need that sleep statement. Without it your main method is done executing and control is go back to TinyCLR which is in the command mode after that.

@ Architect -

Thanks. That is what I thought but I wanted to ask some “EXPERT” to be sure!

@ willgeorge - Just to add to what @ Architect has said.

Using Thread.Sleep(-1) is the best approach for keeping your code active in .NETMF. In native code you will often see that they use a infinite loop to keep the application active, but that is a very bad approach in .NETMF.

@ taylorza -

Thanks for the reply!

and there’s an enum called timeout.infinite in System.threading that’s the same as -1 and a heap less “random” or cryptic.