Another software question USB RAW

I was using some sample code found at:
http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation%20v4.1/html/cad016bc-c045-3553-16a5-a86db398c68f.htm

USBH_RawDevice Class - The following will read a USB mouse data.

I was using this example as a base for some code for reading a joystick raw data.

As a note: I am using a Fez.Spider

The sample uses a Sleep Forever loop Thread.Sleep(Timeout.Infinite) in the method Main()

Other sample code does not use a Sleep Forever loop.

Code generated with Visual Studio (Gadgeteer Designer Program.generated.cs) method Main does not use/show a Sleep Forever loop.

Can anyone take the time to explain the difference?

This is asked only to put my mind at ease.

If you are using Gadgeteer (which is where program.generated comes from) you must NOT use a thread.sleep(timeout.forever) (or a while(true) loop) in the ProgramStarted().

Basically, “sleep forever” stops a netmf app from “terminating”. If you think about what netmf devices were originally (or are still) meant to do, they’re meant to run forever doing the same thing, so the apps should never “end”; the thread.sleep means that the thread stays alive but asleep. So that’s why other examples use the sleep, or a while(true) loop.

In Gadgeteer, there is a layer on top of the netmf that manages it’s own dispatcher, and therefore never sleeps.

http://blogs.msdn.com/b/net_gadgeteer/archive/2011/12/19/why-not-while-true.aspx

Brett

Thank You

In Gadgeteer, there is a layer on top of the netmf that manages it’s own dispatcher, and therefore never sleeps.

That answers my question.