C# 很好地介绍了 .NET Reactive Framework

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1596158/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 19:10:53  来源:igfitidea点击:

Good introduction to the .NET Reactive Framework

c#.netasynchronoussystem.reactive

提问by LBushkin

Aside from the Microsoft documentation, is there a good introduction and tutorial to the Microsoft Reactive (Rx) framework?

除了 Microsoft 文档之外,是否有关于 Microsoft Reactive (Rx) 框架的很好的介绍和教程?

Also, what is a good example (with code) that Reactive makes easier of a programming problem that is challenging to solve using conventional asynchronous coding techniques?

此外,Reactive 使使用传统异步编码技术难以解决的编程问题变得更容易的一个很好的例子(带代码)是什么?

采纳答案by LBushkin

Here's a wiki site with lots of code examples demonstrating how to use different features of the .NET Rx framework: http://rxwiki.wikidot.com/101samples

这是一个包含大量代码示例的 wiki 站点,演示了如何使用 .NET Rx 框架的不同功能:http: //rxwiki.wikidot.com/101samples

I found this to be the most comprehensive site out there, and the one that's quickest to get started with.

我发现这是最全面的网站,也是最快上手的网站。

回答by James Black

You may find this series of articles (there are four) about reactive LINQ useful: Reactive programming (II.) - Introducing Reactive LINQ.

您可能会发现有关反应式 LINQ 的本系列文章(共有四篇)很有用: 反应式编程 (II.) - 反应式 LINQ 简介

He has an example of writing a game using it, so it should hopefully be what you are looking for.

他有一个使用它编写游戏的例子,所以它应该是你正在寻找的。

回答by Matt Breckon

Does your "excluding Microsoft documentation" clause extend to the videos on Channel 9?

您的“排除 Microsoft 文档”条款是否适用于第 9 频道的视频?

From the creator of the reactive framework Erik Meijer: - Expert to Expert: Brian Beckman and Erik Meijer - Inside the .NET Reactive Framework (Rx)

来自响应式框架 Erik Meijer 的创建者: -专家到专家:Brian Beckman 和 Erik Meijer - Inside the .NET Reactive Framework (Rx)

Brand new: Getting Started with Rx Extensions for .NET

全新.NET 的 Rx 扩展入门

回答by FrenchData

I also found Introducing the Reactive Framework Part Ion CodeBetter.com. There is a sequel to the first part on the same site.

我还发现导入反应框架第一部分CodeBetter.com。在同一站点上有第一部分的续集。

I hope this will help you.

我希望这能帮到您。

回答by Benjol

Here's an example of something that is easy to do with reactive programming, but messy (if not challenging) with classic events, it draws lines while the mouse button is down. It is readable, there is no explicit state handling:

这里有一个例子,它很容易用反应式编程来完成,但对于经典事件来说很麻烦(如果没有挑战的话),它会在鼠标按钮按下时画线。它是可读的,没有明确的状态处理:

var pen = new Pen(Color.Red, 3);
var graphics = this.CreateGraphics();

var mouseMoveWhileDown = 
    from md in this.GetMouseDown()
    from mv in this.GetMouseMove().Until(this.GetMouseUp())
    select new Point(mv.X, mv.Y);

mouseMoveWhileDown
    .Pairwise()
    .Subscribe(tup => graphics.DrawLine(pen, tup.Item1, tup.Item2)); 

(I must confess that in that example, Pairwise() is home-grown...)

(我必须承认,在那个例子中, Pairwise() 是本土的......)

The most important thing about IObservable is that it is 'composable', just like IEnumerable.

IObservable 最重要的一点是它是“可组合的”,就像 IEnumerable 一样。

I thouroughly recommend the video mentioned in another answer. In fact there are several different videos on the subject on Channel9:

我彻底推荐另一个答案中提到的视频。事实上,Channel9 上有几个关于这个主题的不同视频:

回答by amazedsaint

Go through these articles, and in particular, download the related source code and play with it.

浏览这些文章,特别是下载相关的源代码并使用它。

Trust this will help

相信这会有所帮助

回答by sweetlilmre

Once you have gone through some of the basic stuff including the HandsOnLabmake sure you check out Lee Campbell's Hot and Cold Observableswhich took some of the arcane mystery out of Rx for me :)

一旦您完成了包括HandsOnLab在内的一些基本内容,务必查看Lee Campbell 的 Hot and Cold Observables,它为我揭开了 Rx 的神秘面纱:)

回答by Lee Campbell

UPDATE: The blog posts below have been superseded by my online book www.IntroToRx.com. It is a comprehensive 19 chapter book available for free. You can browse it on the web, or download the mobi version for your kindle. You can also get it direct from Amazon for a tiny fee (~99c / 77p). If the book doesn't meet your needs or expectations, let me (the Author) know and we will do better for v2.

更新:下面的博客文章已被我的在线书籍www.IntroToRx.com取代。这是一本全面的 19 章书,免费提供。您可以在网络上浏览它,也可以为您的kindle 下载mobi 版本。您也可以直接从亚马逊购买,只需支付少量费用(~99c / 77p)。如果这本书不能满足您的需求或期望,请告诉我(作者),我们会为 v2 做得更好。

Thanks for the link to the Hot/Cold post. This is only one part of the full series,

感谢您提供热/冷帖子的链接。这只是整个系列的一部分,

  1. Introduction to Rx
  2. Static and extension methods
  3. Lifetime management – Completing and Unsubscribing
  4. Flow control
  5. Combining multiple IObservable streams
  6. Scheduling and threading
  7. Hot and Cold observables
  8. Testing Rx
  9. Buffer, Window, Join and Group Join
  1. Rx 简介
  2. 静态和扩展方法
  3. 终身管理 - 完成和取消订阅
  4. 流量控制
  5. 组合多个 IObservable 流
  6. 调度和线程
  7. 冷热观察
  8. 测试接收
  9. 缓冲区、窗口、加入和组加入

I will keep updating this blog with more Rx introductory stuff.

我会继续用更多的 Rx 介绍性内容更新这个博客。

For more advanced stuff you want to go to the Rx Forum(MSDN).

有关更高级的内容,您可以访问Rx 论坛(MSDN)。

回答by John C

DEVHOL202 – Curing the asynchronous blues with the Reactive Extensions for .NET(PDF, 2 MB) is the best lab/tutorial I've seen so far. It guides you through the basics of the library, so that you can build and design on what you've learned.

DEVHOL202 – 使用 Reactive Extensions for .NET(PDF, 2 MB) 解决异步忧郁症是迄今为止我见过的最好的实验室/教程。它会引导您了解库的基础知识,以便您可以根据所学内容进行构建和设计。

There is also a JavaScript version. Search Google for "Reactive Extensions Hands on Lab".

还有一个 JavaScript 版本。在 Google 上搜索“Reactive Extensions Hands on Lab”。