Spring tour behind the scenes, part one

So, we just completed the Calgary delivery of the MSDN spring tour. From all accounts, it was a great success. It was our second delivery of the content, and I think it went well.


We’ve had a lot of fun putting the content together (a lot of work, but a lot of fun). The demo for the winforms stock client was fun to build.  We started with a basic version that was written using Beta 1 of Whidbey, and went through the process of fixing the app to work with Beta 2. In the process, learned a lot about some of the new features in the framework.


For example, we’ve been talking for some time about smart client applications as a very powerful way of building and distributing applications. We have a great framework for this from our Prescriptive Architecture Group (see http://www.microsoft.com/patterns for more info) for the Framework 1.1. There are some significant new features in the 2.0 Beta 2 framework that makes building smart client applications just so much easier.


To recap, a smart client application:

-Works well online and offline

-Is smart about its network state

-Uses the local power of the pc to provide an enhanced experience

-Can update itself automagically J


Two things that I want to highlight that just make life so much better:


1) New networking classes


public delegate NetworkAddressChangedEventHandler

    Member of System.Net.NetworkInformation

public delegate NetworkAvailabilityChangedEventHandler

    Member of System.Net.NetworkInformation


Creating event handlers for these new events makes it dead simple to allow your application to be notified about network stack changes, and allows you to implement the necessary logic to handle moving form online to offline and back.


For example, the stock client app uses the following:


            NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkAvailabilityChangedHandler);

        private void NetworkAvailabilityChangedHandler(object sender, NetworkAvailabilityEventArgs e)


                     if (!_isforcedoffline )


                           if (e.IsAvailable)



                                  _isonline = true;





                                  _isonline = false;





            Once hooked, the _isonline bool is used throughout the application to determine how to handle specific tasks, where to go to get information, etc.


2) Click-Once deployment


We public the application to an IIS box, where any client can browse to install the application on their box, or run the complete setup program. We choose that the application should be available both offline and online, and so a start menu item is created on the client machine. Additionally, the application checks before launching if a new version is available, and can automatically install that version.


One of the cooler things you can do here is have the public operation create a complete setup program for you, and include an autorun.inf to launch it if you decide to distribute the application on CD to, say, remote clients.


More to come…