本文整理汇总了C#中Subject.Throttle方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.Throttle方法的具体用法?C# Subject.Throttle怎么用?C# Subject.Throttle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject.Throttle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CurveDrawingSurface
public CurveDrawingSurface(
ICurvePool curvePool,
InputReference inputReference)
{
RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.Linear);
// Wichtig für "Pan" und "Zoom"
ClipToBounds = true;
_curvePool = curvePool;
_curvePool.CurveAdded += OnCurveAdded;
_curvePool.CurveRemoved += OnCurveRemoved;
inputReference.InputElement.MouseMove += (s, e) => HandleMouseMove(e);
inputReference.InputElement.MouseLeave += (s, e) => HandleMouseLeave(e);
inputReference.InputElement.MouseLeftButtonUp += (s, e) => HandleMouseLeftButtonUp(e);
inputReference.InputElement.MouseLeftButtonDown += (s, e) => HandleMouseLeftButtonDown(e);
inputReference.InputElement.MouseRightButtonUp += (s, e) => HandleMouseRightButtonUp(e);
inputReference.InputElement.MouseRightButtonDown += (s, e) => HandleMouseRightButtonDown(e);
_redrawSubject = new Subject<object>();
_redrawSubject
//.Skip(1)
.Throttle(TimeSpan.FromMilliseconds(50))
.Subscribe(it => _redrawEvent.Set());
_redrawThread = new Thread(RedrawThreadProc);
_redrawThread.IsBackground = true;
_redrawThread.SetApartmentState(ApartmentState.STA);
_redrawThread.Start();
}
示例2: SettingsModel
public SettingsModel()
{
// create a new subject to observe
_subject = new Subject<object>();
// throttle the subject so it will invoke single SettingsChangedEvent only
// after 1 second to avoid numerous tight invocation
_subject.Throttle(TimeSpan.FromMilliseconds(1000))
.Subscribe(o => _eventAggregator.GetEvent<SettingsChangedEvent>().Publish(o));
}
示例3: Throttling
public void Throttling()
{
var received = new List<string>();
var events = new Subject<string>();
events.Throttle(TimeSpan.FromMilliseconds(100)).Subscribe(i => received.Add(i));
events.OnNext("f");
events.OnNext("fr");
events.OnNext("fro");
events.OnNext("from");
Thread.Sleep(120);
events.OnNext("s");
events.OnNext("sc");
events.OnNext("sco");
events.OnNext("scot");
events.OnNext("scott");
Thread.Sleep(120);
Assert.AreEqual("from scott", String.Join(" ", received));
}