by Michael Kennedy
I have been reviewing some of our upcoming classes at DevelopMentor this week. One of those classes,
What’s New in .NET 4.0, left me excited for things to come.
There are a bunch of small but wonderful features discussed in that class. I thought I’d take this opportunity to write a few of them up and share the joy. I bet some of them make you smile too.
- The Parallel Extensions for The .NET Framework will be built into mscorlib.dll.
The fact that PFx will be part of the core .NET library says a lot about how much faith and support it’s getting within Microsoft. BTW, here are some really great demos for PFx in .NET 4.0.
- PFx introduces a new threading construct: Barrier<T>.
Barrier lets you define rendezvous points in your code where multiple concurrent operations can automatically sync-up. Here’s an example.
- Code contracts.
Code contracts allow you to assert truths about your code as if you are writing a unit test. But these assertions live within your production code and are both verified by the compiler as well as the runtime. Here’s the original research project that lead to this feature on Microsoft Research.
- The WPF and Silverlight designers mostly work.
Now this shouldn’t be a point to make me smile or get excited about, but it is. The pain and suffering around the Visual Studio support for WPF and Silverlight designers has been so bad that a mostly-working, and sometimes truly innovative design-time experience within Visual Studio gives me real hope for these technologies. I’m actually excited about them now.
- Support for the MVVM pattern across both WPF and Silverlight.
Speaking of that XAML stuff, if you write WPF or Silverlight code and don’t know MVVM, stop reading this article and tp://msdn.microsoft.com/en-us/magazine/dd419663.aspx" target="_blank">learn about it here. I’ll wait. Ok, now you too should be excited to hear that there is improved support for MVVM across Silverlight and WPF in a unified way. Smiles baby!
- WF (Windows Workflow Foundation) has an AsyncCodeActivity class.
If you have looked at long-running workflows in .NET 3.5 you know they were hard. I even wrote about them. WF 4 has a class which has a BeginExecute / EndExecute pair of methods which much more closely models the regular .NET async design patterns.
- WF has a rehostable designer (really, they mean it this time).
There are some great uses for giving regular users a WF designer experience with the right granularity of activities. Now it’s much easier. Here’s an app that rehosts the designer:

- Configuration-free WCF Hosting.
WCF services is now like hosting ASMX web services if you like the defaults. Just throw out a server + contract + address and it’s up and running. That’ll save a bunch of <system.servicemodel> configuration goo. Smiles!
- No more *.svc in our RESTful urls in IIS.
With the ASP.NET routing framework and WCF REST introduced in .NET 3.5, we can create beautiful, expressive Uri’s for our websites. For example:
http://lookatthiswith.me/watch/intro
But this falls apart with WCF REST when we host it in IIS. Our service Uri’s look like this:
http://lookatthiswith.me/services/lookieservice.svc/lookup/json/cf7
And now we have this ugly .svc part-way through our Uri! Ick. Well, in .NET 4 that Uri is much more customizable and the .svc is gone. Smiles!
- ASP.NET MVC has wicked JavaScript support.
JQuery is there by default. That’s awesome. But there is also a class similar to the Html class (for HTML helpers) called Ajax. This static class has functions like Ajax.ActionLink and effectively brings the functionality of UpdatePanel to MVC!
Michael Kennedy is an instructor for DevelopMentor where he specializes in core .NET technologies as well as agile and TDD development methodologies. Keep up with Michael via his Web site and blog at
http://www.michaelckennedy.net or on Twitter:
@mkennedy.