Reactive Extensions
看异步调用时 看到RX与LINQ用法类似,但是实现机制不同。
Rx最显著的特性是使用可观察集合(Observable Collection)来达到集成异步(composing asynchronous)和基于事件(event-based)的编程的效果。
public partial class MainPage : PhoneApplicationPage
{
readonly List<String> fruits = new List<string>{
"Apple","Orange","Banana","Pears","melon"};
// 构造函数
public MainPage()
{
InitializeComponent();
PopulateCollection();
}
private void PopulateCollection()
{
//使用Enumerable集合进行填充
fruits.ForEach(fruit => lblEnumerable.Items.Add(fruit));
//使用Observable集合进行填充
IObservable<String> observable = fruits.ToObservable();
observable.Subscribe(fruit => lblObservable.Items.Add(fruit));
}
}
http://blog.csdn.net/fangxing80/article/details/7381619
http://www.cnblogs.com/yangecnu/archive/2012/04/17/Introducting_LINQ_And_ReactiveExtensions.html

浙公网安备 33010602011771号