Erik Meijer: Rx in 15 Minutes - Rx is Here!!!!!

Download this episode

Download Video

Download captions

Download Captions

Description

Reactive Extensions for .NET, Rx, is here!!!

Erik Mejier explains what Rx is and why it matters in 15 minutes or less!

Embed

Format

Available formats for this video:

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

    The Discussion

    • User profile image
      tomkirbygre​en

      Rx and MEF are my two favourite new additions to the v4 BCL. Just awesome to see so much care, thought and love going into the platform.

    • User profile image
      GrantB

      Could you (would you) use RX for file or socket I/O?

      If so how would you compare it to IO Completion Ports?

       

    • User profile image
      J.Van.Gogh

      As Rx is a library to orchestrate, not perform asynchronous operations, you would use the Async IO features from .NET and use Rx to react to the completion of the IO:

      standard async IO:

      var fs = new FileStream(@"d:\temp\test.txt", FileMode.Open,
      
        FileAccess.Read, FileShare.Read, 1, true); 
      var data = new byte[fs.Length]; 
      fs.BeginRead(data, 0, data.Length, (result) => 
      { 
        var bytesRead = fs.EndRead(result);
        Console.WriteLine("{0} bytes read.", bytesRead); 
      }, null); 
      

       

      with Rx:

       
      var fs = new FileStream(@"d:\temp\test.txt", FileMode.Open, FileAccess.Read, 
        FileShare.Read, 1, true); 
      var data = new byte[fs.Length];
      var asyncRead = Observable.FromAsyncPattern<byte[], int, int, int>(
        fs.BeginRead, iasyncResult => fs.EndRead(iasyncResult)); 
      var result = asyncRead(data, 0, data.Length); 
      result.Subscribe(bytesRead => Console.WriteLine("{0} bytes read.", bytesRead)); 
      

       

      Now this is a small  sample, but the main difference is that in the latter, the result of the async operation is a first-class value. This means that you can pass the event stream around, do various operations on it (such as select, merge, selectmany, zip etc...), post the result to the UI thread, etc...

       

    • User profile image
      aL_

      in a bit of shameless self promotion, check out my project

      http://geny.codeplex.com/

      its a code generator that generate observable versions of various other things such as events Smiley

      the generation doesnt quite work yet because i needed a release like this to make it work, but check back soon Smiley

    • User profile image
      aL_

      a question, Rx is available for .net3.5 but it uses pfx, how does that work? is there a version of pfx included in the .net 3.5 release?

       

      --edit--

      yes it is Smiley

       

      --edit2--

      http://geny.codeplex.com/ has now  been updated to wor with the new Rx release! there is still no release and im planning to backport it to vs2008 [might be trivial though] but the trunk is now able to create extension methods that return observable methods from events Smiley

    • User profile image
      GamlerHart

      Awsome. I'm definatly going to check it out =)

    • User profile image
      jamiet

      Hey folks,

      Where can we find the Rx dev labs? I've looked around (e.g. http://msdn.microsoft.com/en-us/aa570323.aspx) but can't find them anywhere!!

       

      -Jamie

    • User profile image
      J.Van.Gogh
    • User profile image
      staceyw


                  var task1 = Task.Create(_ =>
                      {
                          "Thanks for back porting TPL to 3.5!".WriteLine();
                      });
                  var task2 = Task.Create(_ => "Thanks for Rx Erik!".WriteLine());
                  Task.WaitAll(task1, task2);
                  "Thanks to all for these wonderful things!".WriteLine();

       

      BTW - what happened to Task.Factory?  I don't see factory class in these Rx 3.5 bits.  But the docs are full of factory samples?  What am I missing?

    • User profile image
      jamiet

      thanks J.

    • User profile image
      aL_

      are you sure they're not in there?

      they seem to bee in

      %programfiles%\Microsoft Reactive Extensions\Redist\DesktopV2\System.Threading.dll

      atleast, perhaps you have another version in the gac or something?

      The correct version should be 1.0.2052.0

    • User profile image
      Maddus Mattus

      Very cool!

    • User profile image
      aL_

      for an approach to turn dependency properties into Observables, check out this thread Smiley

      http://channel9.msdn.com/posts/J.Van.Gogh/Writing-your-first-Rx-Application/

    • User profile image
      staceyw

      "The correct version should be 1.0.2052.0"

       

      My version was 1.0.3058.34407 downloaded with the .Net 3.5 link.  No Future either.  I am guessing this backported version is slimmed down to just the bones they needed for Rx.

    • User profile image
      aL_

      ok.. mine is 1.0.2052.0 atleast Smiley downloaded the 3.5 version on this box no more than an hour ago

      maybe someone from the team can shed some light on this?

       

      (wasnt Future replaced by Taks<T> by the way? )

    • User profile image
      J.Van.Gogh

      Sounds like you have the June 2008 CTP version of Pfx installed on your machine, their version number was 1.0.3058.34407. Try going through your installed program list to see if it is still there by anychance and uninstall that before installing Rx...

    • User profile image
      staceyw

      "Sounds like you have the June 2008 CTP version of Pfx installed on your machine"

       

      You sir are steely eyed missle man.  That was the issue.  Explains a lot of other things have been knocking head on.

    • User profile image
      kiranj

      I like the concept of explaining in 15 min. To the point. Keep up the good work

    • User profile image
      koolraaga

      Brilliant and Interestingly Explained.

       

      Thx for this Video !!!

    • User profile image
      Gravitas

      Great video - my friend recommended Rx, and the penny dropped for the first time after watching this video.

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.