What's different about the 3 versions of Rx? Part 1: Silverlight 3

Download this episode

Download Video


Today we released Reactive Extensions for .NET 3.5 SP1, Silverlight 3 and .NET 4 Beta 2. In this 3 part video, I'll go over the small differences in each of the three releases.

This first video will focus on Silverlight 3.



Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image

      For the March 2010 version of Rx, the code needs to be adjusted as follows:


       Observable.Start(() =>
                                  //return "Hello World";
                              }).ObserveOnDispatcher().Subscribe(_ => button.Content = "Hello World");

      Note the addition of ObserveOnDispatcher above as compared to its absence in the video.


      Lastly, the original code:


      ThreadPool.QueueUserWorkItem(_ =>
                                  button.Dispatcher.BeginInvoke(() =>
                                          button.Content = "Hello World!";
                              }, null);

      Is quite terse as well.  Compared to my revised version, I'm not sure the character count is all that different.


      Nice Rx sample.  Qualifies as the "Hello World!" of Rx for Silverlight and other ilks ... here's a console app version:


      namespace HelloWorld
          class Program
              static void Main(string[] args)
                  Console.WriteLine("Creating ...");

                  var o = Observable.Start(() =>

                  }).Subscribe(_ => Console.WriteLine("Hello World!"));

                  Console.WriteLine("Created ...");

                  Console.WriteLine("Starting ...");



      For WPF its:

      <!-- Window1.xaml -->

      <Window x:Class="HelloWorld.Window1"
          Title="Window1" Height="300" Width="300">
           <Button x:Name="button" Margin="63,47,77,0" VerticalAlignment="Top" Height="60" Content="Button"/>


      // Window1.xaml.cs

      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Windows;
      using System.Windows.Controls;
      using System.Windows.Data;
      using System.Windows.Documents;
      using System.Windows.Input;
      using System.Windows.Media;
      using System.Windows.Media.Imaging;
      using System.Windows.Navigation;
      using System.Windows.Shapes;
      using System.Threading;

      namespace HelloWorld
          /// <summary>
          /// Interaction logic for Window1.xaml
          /// </summary>
          public partial class Window1 : Window
              public Window1()
         button.Click += (o, e) =>
          // button.Content = "Hello World";
          Observable.Start(() =>
          }).ObserveOnDispatcher().Subscribe(_ => button.Content = "Hello World!");


      All very similar.  Now all we need is the Winforms variations.

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.