Skip to Content
C#并发编程经典实例(第2版)
book

C#并发编程经典实例(第2版)

by Stephen Cleary
November 2020
Intermediate to advanced
226 pages
5h 34m
Chinese
Posts & Telecom Press
Content preview from C#并发编程经典实例(第2版)
72
6
49: Saw 93 items.
50: Saw 98 items.
51: Saw 39 items.
52: Saw 0 items.
53: Saw 4 items.
54: Saw 0 items.
55: Saw 58 items.
讨论
利用
Buffer
Window
这样的工具,可以将输入塑造成期望看到的样子。另一个实用的技
巧是节流,参见
6.4
节。
Buffer
Window
都有其他的重载,可以在更高级的场景中使用。带有
skip
参数和
timeShift
参数的重载既可以创建与其他分组重叠的分组,也可以在组与组之间跳过元素。还有一些重
载接受委托,可用于动态定义分组的边界。
参阅
6.1
节探讨从事件中创建序列。
6.4
节探讨如何节流事件流。
6.4
 通过节流和采样控制事件流
问题
在编写响应式代码时,事件传入过快是常见的问题,但是高速运行的事件流会使程序不堪
重负。
解决方案
为了应付事件数据的洪流,
System.Reactive
提供了专门的运算符。
Throttle
(节流)和
Sample
(采样)提供了两种“驯化”高速输入事件的途径。
Throttle
运算符创建一个滑动的超时窗口。当事件到达时,它会重置超时窗口。当超时窗
口过期时,它会发布最后一个到达窗口的事件值。
下面的示例监听鼠标移动,当且仅当鼠标静止整整
1
秒后,才通过
Throttle
运算符汇报
更新:
private void
Button_Click(
object
sender, RoutedEventArgs e)
{
System.Reactive ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley
PHP编程:第4版

PHP编程:第4版

Kevin Tatroe, Peter MacIntyre

Publisher Resources

ISBN: 9787115550606