<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">.NET Micro Framework</title><subtitle type="html">Team Blog</subtitle><id>http://blogs.msdn.com/b/netmfteam/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/b/netmfteam/atom.aspx" /><generator uri="http://telligent.com" version="5.6.583.19849">Telligent Community 5.6.583.19849 (Build: 5.6.583.19849)</generator><updated>2010-12-06T13:45:43Z</updated><entry><title>New NETMF Book out for v4.1 and v4.2</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2012/01/09/new-netmf-book-out-for-v4-1-and-v4-2.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2012/01/09/new-netmf-book-out-for-v4-1-and-v4-2.aspx</id><published>2012-01-09T21:46:07Z</published><updated>2012-01-09T21:46:07Z</updated><content type="html">Some of our earliest partners from SJJ Embedded Micro Solutions - Sean Liming and John Malin - have written a book on the latest versions of NETMF.&amp;#160; The book is targeted at the professional audience, hence the name - “Professional's Guide To .NET Micro Framework Application Development”,but generic enough for anyone.&amp;#160; The book provides a thorough background followed by treatments on the processing loop (threads, priorities, etc), hardware interfaces (Serial, PWM, GPIO, A/D, Ethernet), Graphical...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2012/01/09/new-netmf-book-out-for-v4-1-and-v4-2.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10254745" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Version 4.2 RTM Today!! (Updated)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/10/04/version-4-2-rtm.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/10/04/version-4-2-rtm.aspx</id><published>2011-10-04T21:13:25Z</published><updated>2011-10-04T21:13:25Z</updated><content type="html">We are glad to announce today the RTM of the .NET Micro Framework version 4.2.&amp;#160; You can download the SDK and PK as well as the all sources from our Codeplex project , client_v4_2 branch, at change number 13620 .&amp;#160;&amp;#160; (We will be distributing 4.2 solely through the Codeplex site this time and not on downloads.microsoft.com) Version 4.2 of the .NET Micro Framework Porting Kit provides the following new features: Remote Firmware Update: The .NET Micro Framework SDK and PK now support updating...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/10/04/version-4-2-rtm.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10220020" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>So you always wanted to be an angel investor</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/10/04/so-you-always-wanted-to-be-an-angel-investor.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/10/04/so-you-always-wanted-to-be-an-angel-investor.aspx</id><published>2011-10-04T20:57:42Z</published><updated>2011-10-04T20:57:42Z</updated><content type="html">KickStarter.com was a new one for me.&amp;#160;&amp;#160; There are dozens of interesting projects out there from movies to technology to children’s books.&amp;#160; What all these things have in common is that they need grass roots funding.&amp;#160; At Kickstarter.com they define a funding target and set a deadline to get it.&amp;#160; Then they put together their case and ask you to commit some money towards that target.&amp;#160; The cool thing is that no money is collected unless the target is reached.&amp;#160; This means...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/10/04/so-you-always-wanted-to-be-an-angel-investor.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10220015" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Cortex Support on NETMF in Open Source Project</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/09/12/cortex-support-on-netmf-in-open-source-project.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/09/12/cortex-support-on-netmf-in-open-source-project.aspx</id><published>2011-09-12T21:05:27Z</published><updated>2011-09-12T21:05:27Z</updated><content type="html">There is a lot of interest in the Cortex M series platforms these days.&amp;#160; One reason that these are interesting for very small devices like .NET Micro Framework is that they use a new instruction set – Thumb2 – that is more compact than the one used in ARM processors like the ARM 7 and ARM 9s that NETMF frequently runs on. We have seen about a 20% reduction in the size of our firmware built with the RVDS tools targeting the Thumb2 instructions.&amp;#160; While there have been ports done to the Cortex...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/09/12/cortex-support-on-netmf-in-open-source-project.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10209596" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>NETMF Version 4.2 Release Candidate 2</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/08/30/netmf-version-4-2-release-candidate-2.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/08/30/netmf-version-4-2-release-candidate-2.aspx</id><published>2011-08-30T21:19:43Z</published><updated>2011-08-30T21:19:43Z</updated><content type="html">We have just posted the second Release Candidate for .NET Micro Framework version 4.2.&amp;#160; We decided to do another release candidate so that we could take a few more features from the community and so that we could get a little more exposure to some fairly esoteric bug fixes.&amp;#160; So, in addition to the stuff that was already in 4.2, the new release includes: - support for the STM32 family processors form ST Micro.&amp;#160; This port was contributed by Oberon Micro Systems (Cuno Pfister and Beat...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/08/30/netmf-version-4-2-release-candidate-2.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10203142" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>NETMF 4.2 Contributor and a Cool Product</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/08/24/netmf-4-2-contributor-and-a-cool-product.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/08/24/netmf-4-2-contributor-and-a-cool-product.aspx</id><published>2011-08-24T15:18:22Z</published><updated>2011-08-24T15:18:22Z</updated><content type="html">It is great to be able to highlight a valuable contribution to the 4.2 codebase and a cool application of the platform at the same time. The contribution is from Richard Scott at Pulsecor ( http://www.pulsecor.com/ ). People have asked for examples of the kinds of products built using the Micro Framework and here is one of the devices in the medical segment. Richard is responsible for the technical design of Pulsecor’s Cardiovascular medical products. “The statistics are that 1 in 3 people will die...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/08/24/netmf-4-2-contributor-and-a-cool-product.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10199743" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>NETMF 4.2 – Regular Expressions</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/08/18/netmf-4-2-regular-expressions.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/08/18/netmf-4-2-regular-expressions.aspx</id><published>2011-08-18T15:38:20Z</published><updated>2011-08-18T15:38:20Z</updated><content type="html">With the 4.2 release just around the corner, I wanted to highlight another contributions from the community – specifically in this case, Regular Expressions. This feature was contributed by Julius Friedman.&amp;#160; Regular Expressions This is desktop compatible although some features like Capture have a more limited scope (i.e. not all the methods are there).&amp;#160; A typical user scenario might be parsing a stream from a serial port like a wireless modem. This implementation is derived from the Jakarta...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/08/18/netmf-4-2-regular-expressions.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10197384" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>NETMF Student and Hobbyist projects</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/08/10/netmf-student-and-hobbyist-projects.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/08/10/netmf-student-and-hobbyist-projects.aspx</id><published>2011-08-10T16:34:41Z</published><updated>2011-08-10T16:34:41Z</updated><content type="html">The last few blogs have highlighted some of the NETMF uses at the Imagine Cup.&amp;#160; These are presumably products that are targeting commercial applications and both of these project teams are exploring the road to bringing their products to market.&amp;#160; There are also some really cool things happening in the student and hobbyist space that I want to shine a little light on.&amp;#160; The first is a great grassroots robotics competition that is driven by the students of UC Berkeley. I spoke with Amy...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/08/10/netmf-student-and-hobbyist-projects.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10194533" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Imagine Cup and NETMF (Part 2)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/08/01/imagine-cup-and-netmf-part-2.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/08/01/imagine-cup-and-netmf-part-2.aspx</id><published>2011-08-01T16:35:01Z</published><updated>2011-08-01T16:35:01Z</updated><content type="html">The team that won the Software Design category was Team Hermes from Sligo, Ireland. This team created an application that addressed the issue of the high rate of traffic fatalities In Ireland with a classically ‘Internet of Things’ solution. They instrumented the car with a device based on a FEZ Panda that plugs into the car’s data interface (the OBD port) as well as supporting their own set of sensors. With this input, they determine the quality of the operators driving instantaneously and continuously...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/08/01/imagine-cup-and-netmf-part-2.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10191706" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Imagine Cup and NETMF (Part 1)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/07/29/imagine-cup-and-netmf-part-1.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/07/29/imagine-cup-and-netmf-part-1.aspx</id><published>2011-07-29T15:20:11Z</published><updated>2011-07-29T15:20:11Z</updated><content type="html">The Imagine Cup just finished an once again there were some great projects as always.&amp;#160; This year, even more than in the past, there were a number of projects that included the .NET Micro Framework platform.&amp;#160; I have had the opportunity to talk with several of the teams about their projects and their experiences with NETMF.&amp;#160; Here is the first one. Technorati Tags: NETMF , .NET Micro Framework , Imagine Cup , Baby Monitor , Kevin Pfister The first team is an stalwart team of one – Kevin...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/07/29/imagine-cup-and-netmf-part-1.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10191137" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Internet of Things and StreamInsight</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/07/12/internet-of-things-and-streaminsight.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/07/12/internet-of-things-and-streaminsight.aspx</id><published>2011-07-12T13:43:32Z</published><updated>2011-07-12T13:43:32Z</updated><content type="html">The Internet of Things (IoT) is gaining momentum with more and more investment from governments and companies being announced all the time.&amp;#160; There is still some complexity to the development of solutions in this segment because the solutions require connecting a wide range of computing devices in new ways, standards are still emerging, and frankly the segment is too diverse for a single set of standards anyway.&amp;#160; That said, Microsoft has a number of really great technologies in this space...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/07/12/internet-of-things-and-streaminsight.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10185540" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>NETMF 4.2 – Other CodePlex NETMF Projects</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/06/27/netmf-4-2-other-codeplex-netmf-projects.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/06/27/netmf-4-2-other-codeplex-netmf-projects.aspx</id><published>2011-06-27T14:11:32Z</published><updated>2011-06-27T14:11:32Z</updated><content type="html">In this latest release of the .NET Micro Framework we have tried to acknowledge some of the great contributions from the community and we will continue to do that.&amp;#160; In addition, there are great contributions happening at our partner’s sites.&amp;#160; There is one set of contributions that I want to point out that may go unnoticed.&amp;#160; There are a number of people working on extensions to the platform that they have elected to put out as separate CodePlex projects and there is some cool and interesting...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/06/27/netmf-4-2-other-codeplex-netmf-projects.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10179432" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>NETMF 4.2 – Porting Kit Studio</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/06/20/netmf-4-2-porting-kit-studio.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/06/20/netmf-4-2-porting-kit-studio.aspx</id><published>2011-06-20T18:47:26Z</published><updated>2011-06-20T18:47:26Z</updated><content type="html">Version 4.2 went to Beta a few days ago with an impressive assortment of contributions from the community.&amp;#160; One contribution stands out for its scope and ambition.&amp;#160; That contribution is the PKStudio contributed by Alexandr Surkov and Igor Kiselev. As anyone who has tried the NETMF Porting Kit, it is not for the faint of heart.&amp;#160; It was built for us to use and we have not gotten back to polishing it up.&amp;#160; Alexandr and Igor have tackled that problem by analyzing the porting kit and...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/06/20/netmf-4-2-porting-kit-studio.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10177119" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>NETMF Version 4.2 Beta now available</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/06/07/netmf-version-4-2-beta-now-available.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/06/07/netmf-version-4-2-beta-now-available.aspx</id><published>2011-06-07T17:24:00Z</published><updated>2011-06-07T17:24:00Z</updated><content type="html">&lt;p&gt;Today, we have posted the Beta bits for the NETMF version 4.2 release to &lt;a href="http://netmf.codeplex.com/"&gt;CodePlex&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;There are some great additional features beyond what we announced for the &lt;a href="/b/netmfteam/archive/2011/03/24/netmf-4-2-alpha-available.aspx"&gt;4.2 Alpha release&lt;/a&gt; (cryptographic primitives, PWM, FTP,&amp;hellip;). These include:&lt;/p&gt;...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/06/07/netmf-version-4-2-beta-now-available.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10172218" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Do You Have a Commercial Product Using NETMF?</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/06/03/do-you-have-a-commercial-product-using-netmf.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/06/03/do-you-have-a-commercial-product-using-netmf.aspx</id><published>2011-06-03T23:22:00Z</published><updated>2011-06-03T23:22:00Z</updated><content type="html">&lt;p&gt;I am always being asked for examples of what NETMF is used for. I am also frequently surprised by what people are doing with it. Since going Open Source, there is not an obvious way for me to find out what people are doing with the product and the result is that my list of applications is getting a little stale&lt;/p&gt;...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/06/03/do-you-have-a-commercial-product-using-netmf.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10171253" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>NETMF at TechEd 2011</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/05/23/netmf-at-teched-2011.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/05/23/netmf-at-teched-2011.aspx</id><published>2011-05-23T14:11:00Z</published><updated>2011-05-23T14:11:00Z</updated><content type="html">&lt;p&gt;Just got back form TechEd 2011 where Microsoft&amp;rsquo;s smallest platform had the biggest booth (no kidding). We also had a lot of help manning the booth &amp;ndash; thanks to all the volunteers there. The word got out that we had some cool demos as well. Here is what we were showing.&lt;/p&gt;...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/05/23/netmf-at-teched-2011.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10167327" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>.NET Gadgeteer Live as an Open Source Project</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/05/02/net-gadgeteer-live-as-an-open-source-project.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/05/02/net-gadgeteer-live-as-an-open-source-project.aspx</id><published>2011-05-02T19:06:00Z</published><updated>2011-05-02T19:06:00Z</updated><content type="html">&lt;p&gt;Over the last 7 months, we have shown the .NET Gadgeteer to a number of internal and external parties. The response is almost always the same &amp;ndash; where can I get one?&lt;/p&gt;...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/05/02/net-gadgeteer-live-as-an-open-source-project.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10160103" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>New Kits from GHI Electronics</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/04/28/new-kits-from-ghi-electronics.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/04/28/new-kits-from-ghi-electronics.aspx</id><published>2011-04-28T15:04:00Z</published><updated>2011-04-28T15:04:00Z</updated><content type="html">&lt;p&gt;In case you haven&amp;rsquo;t been out to the GHI site in the last few days, they just &lt;a href="http://www.ghielectronics.com/catalog/category/38"&gt;announced a new set of kits&lt;/a&gt;. These kits are intended to give you an easy on-ramp to building things. &lt;/p&gt;...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/04/28/new-kits-from-ghi-electronics.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10159147" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>The Curious Cloud Contest</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/04/19/the-curious-cloud-contest.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/04/19/the-curious-cloud-contest.aspx</id><published>2011-04-19T15:54:00Z</published><updated>2011-04-19T15:54:00Z</updated><content type="html">&lt;p&gt;It has been a busy month getting ready for MIX 2011 in Las Vegas last week. We put together a cool challenge for some of the attendees &amp;ndash; a challenge that was maybe a little too challenging but still fun.&lt;/p&gt;...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/04/19/the-curious-cloud-contest.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10155788" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>NETMF 4.2 Alpha Available</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/03/24/netmf-4-2-alpha-available.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/03/24/netmf-4-2-alpha-available.aspx</id><published>2011-03-24T17:06:00Z</published><updated>2011-03-24T17:06:00Z</updated><content type="html">&lt;p&gt;I&amp;rsquo;m a bit tardy on this announcement since the release has been available for almost 10 days now but things are pretty busy here. On March 15th, we posted an alpha version of the 4.2 release. The features that are available in this early look are security improvements, FTP Support, a PWM Object, and a number of fixes to the issues that you have reported in the &lt;a href="http://netmf.codeplex.com/workitem/list/advanced"&gt;issue tracker&lt;/a&gt; on the&lt;a href="http://netmf.codeplex.com/workitem/list/advanced"&gt; CodePlex project&lt;/a&gt;.&lt;/p&gt;...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/03/24/netmf-4-2-alpha-available.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10145463" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Thread Communication and Synchronization</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/02/01/thread-communication-and-synchronization.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/02/01/thread-communication-and-synchronization.aspx</id><published>2011-02-01T18:16:00Z</published><updated>2011-02-01T18:16:00Z</updated><content type="html">&lt;p&gt;After the last blog on &lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/01/17/threads-and-thread-priorities-in-netmf.aspx"&gt;Threads and Thread Priorities&lt;/a&gt;, readers asked for a continuation on Thread Communication and Synchronization. Before I jump in, I have to reiterate that concurrency is a complex issue. I won&amp;rsquo;t try to compete with the technical books on the subject that run to hundreds of pages. I will focus on some basic examples of what is available in NETMF to support the concepts introduced in books like that. That means that you can take what you learn here and still get trouble if you are not careful.&lt;/p&gt;
&lt;h2&gt;Shared Resources &amp;ndash; Locking Critical Sections&lt;/h2&gt;
&lt;p&gt;The most common interaction between threads is through shared resources. We can define a static resource that several threads can interact with. Here is a simple example where I have the main thread and one additional thread &amp;ndash; both of which use a counter (s_IncCounter). The main thread prints it out and the worker thread increments it 5 times and then checks its work.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;private static int s_IncCount = 0; &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;public static void Main() &lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread thread1 = new Thread(Thread1); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; thread1.Start(); &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (true) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.Sleep(5000); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print("Thread Execution Count = " + s_IncCount); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;} &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;private static void Thread1() &lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (true) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int j = 0; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; 5; i++) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s_IncCount++; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int ii = 0; ii &amp;lt; 1000; ii++) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j = s_IncCount % 5; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (j != 0) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print("s_IncCount % 5 is: " + j.ToString()); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;} &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The output of the execution of this application shows that we are getting slightly fewer than 700 increments every 5 seconds. We will use this measurement to see what the overhead of the thread synchronization mechanisms are. Also notice that the worker thread checks to see if exactly 5 increments have been done. There are no instances where we see that error message. It doesn&amp;rsquo;t mean that there is not some interaction between the two threads but since only one is writing to the shared resource (s_IncCounter), the interactions don&amp;rsquo;t have any side-effects.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-89-90-metablogapi/7411.clip_5F00_image001_5F00_2BD1AEBE.png"&gt;&lt;img height="210" width="244" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-89-90-metablogapi/4784.clip_5F00_image001_5F00_thumb_5F00_54AC9DFA.png" alt="clip_image001" border="0" title="clip_image001" style="display: inline; border-width: 0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now let&amp;rsquo;s add a second thread. This one exactly matches the first worker thread.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;private static void Thread2() &lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (true) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int j = 0; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; 5; i++) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s_IncCount++; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int ii = 0; ii &amp;lt; 1000; ii++) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j = s_IncCount % 5; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (j != 0) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print("s-IncCount % 5 is: " + j.ToString()); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;}&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We start both threads in the main thread.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;thread1.Start(); &lt;br /&gt;thread2.Start();&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When we run these, we immediately see that both threads are reporting problems. Thread 1 is being interrupted in the middle of making its 5 increments and then Thread 2 starts up from there and runs some unknown number of times. The result can be seen below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-89-90-metablogapi/4760.clip_5F00_image002_5F00_745B77C2.png"&gt;&lt;img height="244" width="188" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-89-90-metablogapi/4452.clip_5F00_image002_5F00_thumb_5F00_34255E48.png" alt="clip_image002" border="0" title="clip_image002" style="display: inline; border-width: 0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Even with three threads competing for time slices, the total throughput (increments/sec) do not change. The thread swapping is very low overhead in NETMF.&lt;/p&gt;
&lt;p&gt;So, what we are seeing is just one of the pitfalls of a multithreaded environment that is called a race condition. That means that the results of your program are being determined by two threads racing against each other to complete their tasks. That is clearly not what you want. For our program to function smoothly, we need the portions of each thread that work on the shared resource to complete entirely (ie increment all 5 times then then swap out). Stated another way, those lines of code need to execute &amp;lsquo;atomically&amp;rsquo; &amp;ndash; as if they were one undisturbed machine instruction. Let&amp;rsquo;s look at the support NETMF has for this.&lt;/p&gt;
&lt;p&gt;First, there is the &lt;b&gt;Interlocked&lt;/b&gt; class that you saw in the previous article. The Interlocked class lets you perform a prescribed set of operations on a resource atomically. That set of operations that are supported are the methods to this class. The syntax for this is &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Interlocked.Increment(ref s_IncCount);&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You might not think you even need this lock &amp;ndash; isn&amp;rsquo;t one line of code an atomic thing in itself? In fact it isn&amp;rsquo;t. To do the increment, the value is copied from the variable and into a register, incremented there, and then copied back to the variable in three separate instructions and the thread can be swapped out anywhere during that time.&lt;/p&gt;
&lt;p&gt;What if you need to do more than the Interlocked class supports (a more complex operation on the resource or operations on several resources) and you need it to all complete before someone else can touch the resources. That is where the Lock mechanism comes in. In our example, we want to execute a number of steps on the counter and test what we did before we let anyone else have access to it. To do this, I first define an object that the will be used by the lock to identify it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;private static object s_IncLock = new object();&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now I add a lock that looks like this in each of our threads:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;private static void Thread1() &lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (true) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int j = 0; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lock (s_IncLock) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print("Lock 1"); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; 5; i++) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s_IncCount++; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int ii = 0; ii &amp;lt; 1000; ii++) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j = s_IncCount % 5; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (j != 0) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print("s_IncCount % 5 is: " + j.ToString()); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;}&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;With these locks, our output no longer has the race condition and the message reflecting the race condition is no longer showing up.&lt;/p&gt;
&lt;p&gt;There is an interesting interaction between the Lock and the thread scheduler. Without the lock, each thread would execute for its 20 mSec before yielding. That would be many iterations of the while loop in each time slice. However, the thread scheduler takes locks into consideration in the following way &amp;ndash; when each thread asks for the lock, the scheduler sees if there is anyone waiting for that lock. The priority goes to the thread that has been waiting the longest so the two threads we have defined end up executing the lock one time each and swapping back and forth. &lt;/p&gt;
&lt;p&gt;The output looks like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-89-90-metablogapi/8081.clip_5F00_image003_5F00_3AD867CB.png"&gt;&lt;img height="244" width="222" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-89-90-metablogapi/0574.clip_5F00_image003_5F00_thumb_5F00_1331EBA1.png" alt="clip_image003" border="0" title="clip_image003" style="display: inline; border-width: 0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Swapping out for each iteration through the while loop still does not change the number of iterations in a measurable way. You can see that locking and thread swapping is REALLY low overhead.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;MethodImplOptions Attribute&lt;/h2&gt;
&lt;p&gt;There is a way to lock a method as opposed to a critical section within a method. That is using the MethodImplOptions attribute. The syntax looks like:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;[MethodImpl(MethodImplOption.Synchronized)] &lt;br /&gt;public void MySynchronizedMethod() &lt;br /&gt;{ &lt;br /&gt;&amp;hellip;. &lt;br /&gt;}&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This locks the method so that only one thread can access it at a time. If one thread is in the method when it is swapped out and another thread tries to access that method, the second thread blocks.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Monitor Class&lt;/h2&gt;
&lt;p&gt;Before we leave locks, it is worth mentioning that NETMF supports the &lt;strong&gt;Monitor&lt;/strong&gt; class which does effectively the same thing as the lock mechanism &amp;ndash; it defines a critical section and blocks other threads from entering that section while there is a lock on it. Monitors are a little more flexible because they are not limited to using braces to define scope. With Monitors, you can exit your Monitor anywhere&amp;ndash; possibly in different paths of execution. This flexibility comes with more risk making it easier to have a path of execution where the Monitor does not Exit(object) or Exit(object) is called more than Enter(object) is called.&lt;/p&gt;
&lt;p&gt;The NETMF Monitor class is simpler than the full .NET Monitor implementation in that it lacks event wait handles. For those, you have to use the mechanisms described next.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Thread synchronization - Events&lt;/h2&gt;
&lt;p&gt;At times, you want to synchronize threads directly &amp;ndash; ie run this thread when another thread enters some specific state. There are two ways to do this &amp;ndash; one general and one used specifically for UI interactions. First let&amp;rsquo;s look at Events.&lt;/p&gt;
&lt;p&gt;Events are the same mechanism that is available on the full .NET Framework with some minor differences. You can define an event that will control the execution of a thread. In the full .NET Framework, there is a richer semantic that supports waiting for one event, one of several events, or all events to occur. In NETMF, we only support waiting for a single event. First you define an event something like this:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;static AutoResetEvent autoEvent = new AutoResetEvent(false);&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This sets up the event in an initial state of &amp;lsquo;false&amp;rsquo;.&lt;/p&gt;
&lt;p&gt;Now let&amp;rsquo;s add a third thread to our sample application that looks like this:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;private static void Thread3() &lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print(" Waiting for 10000 iterations"); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; autoEvent.WaitOne(); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print("Finally got the 10000 iterations"); &lt;br /&gt;}&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This thread is entered on its Start() call and prints out the message that it is waiting for 10000 iterations and then enters a suspended state until the event triggers (becomes true). In the other threads we add a test after we increment:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;if (s_IncCount &amp;gt;= 10000) &lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; autoEvent.Set(); &lt;br /&gt;}&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When the event is Set(), the third thread is unblocked and the scheduler will pick it up quickly since it hasn&amp;rsquo;t run in some time. Thread3 writes out its second message and then exits and the other threads continue as expected.&lt;/p&gt;
&lt;p&gt;The semantics of the AutoResetEvent class are that when set to false (unsignalled) it will block any thread calling the WaitOne() method on that event. Once the event is signaled by someone calling the Set() method on that event the AutoResetEvent unblocks the thread and then returns to the unsignalled state once again blocking. The MaunalResetEvent supports a slightly different set of behaviors. The ManualResetEvent also unblocks threads that have a WaitOne() call when the event is Set(). However, the ManualResetEvent does not automatically go back into an unsignalled state one it unblocks the thread. It stay in a signaled state until its Reset() is called. That means that all calls to WaitOne() return immediately.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Thread Synchronization with the Dispatcher &lt;/h2&gt;
&lt;p&gt;If you have created a graphical UI for your application using NETMF, then you actually have another thread that is created by the CLR &amp;ndash; this is the Dispatcher thread that coordinates the access to all of the UI elements in a thread safe manner. The fact that you now have at least two threads means that you have to manage the access to anything that might be a shared resource. Since your UI logic is sharing the UI elements with the CLR created thread which is actually rendering them and there is no way to define a lock that the Dispatcher thread knows about, there is a different way to safely update the UI resources. &lt;/p&gt;
&lt;p&gt;The way to synchronize the two threads is to not execute the code that interacts with the UI Elements on your thread but to execute it on the Dispatcher thread instead. To do this, you define a delegate that the Dispatcher will call back to, you implement the delegate, and you call Dispatcher.BeginInvoke when you want the Dispatcher to invoke your method. (There is also a Dispatcher.Invoke call that is synchronous so you need to define a maximum amount of time you will allow this call the wait for delegate to be called.) There is a previous blog on this topic specifically The Dispatcher and DispatchTimer called &lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2008/03/04/using-the-dispatcher.aspx"&gt;Using the Dispatcher&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;p&gt;This is a rather long blog but this is also a fairly complex subject. We have covered Interlocked, locks, MethodImplOptions, Monitors, Events, and (indirectly) synchronizing with the Dispatcher. Hopefully this is helpful.&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/.NET+Micro+Framework"&gt;.NET Micro Framework&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/NETMF"&gt;NETMF&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Threads"&gt;Threads&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Thread+Communication"&gt;Thread Communication&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Thread+Synchronization"&gt;Thread Synchronization&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Locks"&gt;Locks&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/InterLocked"&gt;InterLocked&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Monitor+Class"&gt;Monitor Class&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Dispatcher"&gt;Dispatcher&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/AutoResetEvent"&gt;AutoResetEvent&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/ManualResetEvent"&gt;ManualResetEvent&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10123277" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Where to find NETMF this Spring</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/01/31/where-to-find-netmf-this-spring.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/01/31/where-to-find-netmf-this-spring.aspx</id><published>2011-02-01T00:15:50Z</published><updated>2011-02-01T00:15:50Z</updated><content type="html">This is a busy spring for conferences for the platform.&amp;#160; Here is a partial list of places that you can look for us.&amp;#160; Spread the word about these events so that people can get hands on with the product and get any questions that they have answered in real time.&amp;#160; You can see what others are doing with the platform as well.&amp;#160;&amp;#160;&amp;#160; It is a great opportunity to grow the community. Embedded World 2011 If you are not familiar with it, Embedded World is the big embedded event for...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/01/31/where-to-find-netmf-this-spring.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10122866" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Threads and Thread Priorities in NETMF</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2011/01/17/threads-and-thread-priorities-in-netmf.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2011/01/17/threads-and-thread-priorities-in-netmf.aspx</id><published>2011-01-17T21:32:23Z</published><updated>2011-01-17T21:32:23Z</updated><content type="html">I started this article with the objective of providing a more up to date discussion of thread priorities. I thought first that I should cover a little about threads just in case. If you are already conversant in threads, jump ahead to the Thread Priorities section. Threads are a valuable part of the .NET MF programming model. They are particularly useful in the common scenarios where you are getting input from a sensor or communicating with other devices. If you have a sensor for example, it is common...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2011/01/17/threads-and-thread-priorities-in-netmf.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10116777" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>A New Book Experience!!</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2010/12/16/a-new-book-experience.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2010/12/16/a-new-book-experience.aspx</id><published>2010-12-16T16:21:45Z</published><updated>2010-12-16T16:21:45Z</updated><content type="html">There is a new book that is not completely out yet but I am really excited about it.&amp;#160; The book is ‘Getting Started with the Internet of Things’ by Cuno Pfister. ( http://oreilly.com/catalog/0636920013037 ) There are a number of reasons that I really like this book – listed below in no particular order: The Subject Matter: The Internet of Things (IOT) is defined as everyday objects connected through the internet.&amp;#160; These can be appliances, cars, health care devices, whatever you can think...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2010/12/16/a-new-book-experience.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10105975" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Need Help Getting Started with NETMF?</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/netmfteam/archive/2010/12/06/need-help-getting-started-with-netmf.aspx" /><id>http://blogs.msdn.com/b/netmfteam/archive/2010/12/06/need-help-getting-started-with-netmf.aspx</id><published>2010-12-06T21:45:43Z</published><updated>2010-12-06T21:45:43Z</updated><content type="html">Updated with new location. and new content description and translation ‘challenge’ Are you a .NET programmer who needs some background in embedded interfaces?&amp;#160; Not sure how to debounce a button or why you might want to do that?&amp;#160; Maybe you even need some help with C#?&amp;#160; Maybe you are not sure where to start with getting your devices to talk to each other?&amp;#160; The folks at GHI electronics (tinyCLR.com) have invested a significant amount of time in building up a beginner’s guide to C#...(&lt;a href="http://blogs.msdn.com/b/netmfteam/archive/2010/12/06/need-help-getting-started-with-netmf.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10100996" width="1" height="1"&gt;</content><author><name>Colin Miller</name><uri>http://blogs.msdn.com/NETMF-Team-Bloggers/ProfileUrlRedirect.ashx</uri></author></entry></feed>
