Hello Reactive Extension !! Rx.Net getting started

Reactive extensions for .Net are an asynchronous event-based programming libraries. They use observable collections for doing so.

I have used Thread Pools, spawning my own threads, Aynsc using Begin and End Invoke pattern and also use Jeff Richter’s APM libraries to do Async programming. Guys who are used to using background worker class have been doing Aynsc programming for a long time already. Well , Why RX then. I don’t know yet. I have heard good things about it and I thought I will play with it a bit. So here it is

  1. Download RX from http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx
  1. Start a new C# console application and add reference to System.Reactive. Please be aware that that you can use RX from Dot Net framework 3.5 onwards so your target framework should be 3.5 or higher . I have downloaded the 3.5 version of RX and using VS 2008 + dot net framework 3.5  so this is what I have in the project properties

 

image001

 

3. Add reference to these libraries

image002

 

  1. Paste this code
using System;
using System.Linq;
using System.Threading;

namespace HelloRx
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var o = Observable.Start(() => { Console.WriteLine("Hello RX."); Thread.Sleep(3000); Console.WriteLine("Done."); });
            o.First();   // subscribe and wait for completion of background operation
        }
    }
}

  1. 5. Hit F5 and you have written your first code using Reactive extensions
About these ads

2 thoughts on “Hello Reactive Extension !! Rx.Net getting started

  1. Click Here says:

    Multiple reasons for light also allow it to be easy
    to adjust the lighting level when working.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: