Sunday, December 18, 2011

Preparing for Reactive Extensions (RX) with LinqPad

In the following series I will show you how to use Reactive Extensions with my favorite scratchpad LINQPad.

Download and Installation
You can find instructions how to download and install RX on this page in the "Download the Reactive Extensions for .NET" section.
LINQPad is downloadable from this site.
Open LINQPad.exe
press F4 and then click Browse.. to add new assemblies from the installation folder (Program Files\Microsoft Reactive Extensions SDK\v1.0.10621\Binaries\.NETFramework\v4.0) in the Additional References tab:
  • System.Reactive
  • Microsoft.Reactive.Testing
You will also need to add the following namespaces without the using statement in the Additional Namespace Imports Tab:
  • System.Threading.Tasks
  • Microsoft.Reactive.Testing
  • System.Reactive
  • System.Reactive.Linq
  • System.Reactive.Subjects
  • System.Reactive.Concurrency
  • System.Reactive.Disposables
Now we will try our first example which will be explained in the next articles. Type the source code as shown below:

void Main()
{
    var source = Observable.Range(1, 5);
    
    source.Subscribe(value => value.Dump());
}
You should see the following results in the result window after pressing Execute (F5):
================
1
2
3
4
5
================

Save the code snippet (Ctrl+S) as a Linq query file. You can create new linq query files with the same settings by pressing Ctrl+Shift+N. I hope that now you are prepared for the upcoming posts.

No comments:

Post a Comment