I recently wrote another article for DevelopMentor's Developments newsletter (not subscribed yet? see top-right of this page). This one is entitled
10 Features in .NET 4.0 that made Me Smile
Read it on the DevelopMentor website: http://www.develop.com/tenfeaturesdotnet4
I am republishing it below for you all to enjoy on your RSS readers.
Cheers,
Michael
10 Features in .NET 4.0 that made Me Smile
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 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.
While WF has traditionally supported both synchronous (activities that execute immediately) and asynchronous activities (for long running senarios where the workflow becomes idle and is unloaded from memory [click here for more details]), there has been an unserved middle ground. If you want to use threading in your activity and allow the workflow to go idle without it being unloaded from memory you were basically out of luck. This is the problem solved by the AsyncCodeActivity. WF 4 now 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.
Hosting WCF services is now like hosting ASMX web services
if you like the defaults. Just throw out a service + 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!
Well there you have it. 10 awesome things in .NET 4 that made me smile this week.
I hope you find some to be welcome additions yourself! If you want to learn more
about .NET 4.0, check out our recorded webcasts here: http://www.develop.com/dotnet4webcasts.
Also have a look at my article from last month
Six Things That’ll Surprise You About
.NET 4.0.
Finally, if you have some training funds laying around, I’d love to spend a week
talking about these ideas with you in our What’s New in .NET 4.0 What’s New in .NET 4.0 class.
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.