Main Site Documentation

G400-D MFConsole projects Debug message


#1

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!


#2

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.


#3

@ Architect -

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


#4

@ 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.


#5

@ taylorza -

Thanks for the reply!


#6

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