开发者

linqpad error using Rx Reactive extensions in c#

开发者 https://www.devze.com 2023-03-12 16:47 出处:网络
What am I doing wrong ? I just downloaded the latest Rx sdk, installed. Using vs 2010, .net 4 have all latest sp/updates etc. Downloaded/installed linqpad, Added reference to the r开发者_开发技巧eacti

What am I doing wrong ? I just downloaded the latest Rx sdk, installed. Using vs 2010, .net 4 have all latest sp/updates etc. Downloaded/installed linqpad, Added reference to the r开发者_开发技巧eactive dll as shown in the attached screenshot. Added the one line as shown in the linqpad demo but get an error when I run. Please advise. Right click on image and view image for clear view.

thanks

linqpad error using Rx Reactive extensions in c#


The download on the Rx home page is not actually the latest Rx SDK. The latest release is on the Reactive Extensions Team Blog site and is currently the Christmas 2010 May 2011 June 2011 release.

In the release you're using, the Observable class is in the System.Reactive.Linq namespace (rather than the System.Linq namespace). Press F4 again and enter System.Reactive.Linq into "Additional Namespace Imports". (Or if you have autocompletion, a smart tag will appear and do the job for you).

This will get you up and running with Rx in LINQPad. Calling .Dump() on an observable is non-blocking, so you can Dump multiple observables at once.

For example:

Observable.Interval(TimeSpan.FromSeconds(1)).Take(5).Dump("1 second");
Observable.Interval(TimeSpan.FromSeconds(.5)).Take(5).Dump(".5 second");

The result:

.5 second → 0
1 second → 0
.5 second → 1
.5 second → 2
1 second → 1
.5 second → 3
.5 second → 4
1 second → 2
1 second → 3
1 second → 4

The query will finish when all the observables have ended (or you press Cancel).

To run another reactive query, press Ctrl+Shift+N. This creates a new query with the same properties (references, namespace imports, etc). Another trick, if you have autocompletion, is to click 'Save as Snippet' after adding the assembly / namespace import. Then whenever you type the shortcut (e.g., 'rx') and press tab, the references and namespaces will be added automatically.


Switch to the other tab in the dialog and add System.Reactive and System.Reactive.Linq in the namespace list

0

精彩评论

暂无评论...
验证码 换一张
取 消