Main Site Documentation

Question: What real-time programming constructs does .NET Micro Framework support


In my opinion, the feature that really distinguishes .NET Micro Framework on FEZ products from other platforms like Arduino, Launchpad, BASIC STAMP/Propeller etc. is multithreading. I have very limited experience on .NET Framework, so please don’t mind if you think the question is too simple. And do reply, because I still need the answer :slight_smile:

Normally, in POSIX compliant operating systems, constructs like message queues and semaphores are available, which come really handy when doing multi-threading programming. What sort of comparative constructs are available in .NET Micro Framework? Are Semaphores, Mutexes and message queues avaialble? I can see Thread.Sleep() is available in .NET Micro Framework. But what about Mutex, Semaphore (seems like they’re available in .NET Framework; don’t know about .NET Micro) etc.? Is there a white paper or an article which discusses multithreading in .NET Micro Framework?


.NET Micro Framework isn’t a real time development platform. Threading is simple, you can read any of the .NET articles on threading even if they don’t reference the Micro Framework, since it’s built off the same architecture it works exactly the same.

There are a lot of thread synchronization constructs in the .NET language, from simple lock() statements all the way to semaphores and sophisticated spin locks.


Thanks for the quick answer. What about inter-thread communication (something comparable to message queues)? What should I look for?


You can use global objects, and generic collections, but I don’t think there is any kind of message queuing in the micro framework. The full framework libraries have methods to send data to threads using the equivalent of a mailbox.

You just have to watch out with global objects that if you have multiple threads accessing them that you synchronize the access otherwise you can run into deadlocks and concurrency issues. You can create your own basic messaging system pretty easily using the generic collections.



You can use .Net synchronization objects. Look inside System.Threading namespace:

Monitor, AutoResetEvent, ManualResetEvent are the ones you need for that.

William also has posted some good helpers classes on Fezzer.

There are other members who have posted useful threading helpers as well.
Just search Fezzer using tag - “thread”.


And Colin’s two recent posts:


[Edit] Somehow I did not see Arcitects post.
NETMF has the core constructs such as AutoResetEvent, ManualResetEvent, Monitor, and Interlocked. With those, you can build any other. In NETMF, no need for kernel mutex, as monitor handles that function. TMK, no native semaphore, but you can create one. Same for a concurrent queue for inter-thread sync. I have posted NETMF versions of some of the more useful classes here.

However, non of these have much to do with real-time programming. These live in the concurrent programming space.


We probably started at the same time. Anyways I have missed countdownevent in my list ;D


I would like to add one more comment.
Although .NET Micro Framework in not a Real Time Operation system. GHI invented something called RLP (Run-time loadable procedures). This feature allows users to load native code (C/Assembly) for higher performance and real-time requirements.

RLP is an exclusive feature from GHI that you can enjoy in any NETMF solution made by GHI.


Thanks everyone for all the information. It will take a while to digest all of it.