当前位置: 首页>>代码示例>>C#>>正文


C# Subject.Throttle方法代码示例

本文整理汇总了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();
        }
开发者ID:Bruhankovi4,项目名称:Emotyper,代码行数:31,代码来源:CurveDrawingSurface.cs

示例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));
        }
开发者ID:Boredude,项目名称:stock-analyzer,代码行数:10,代码来源:SettingsModel.cs

示例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));
        }
开发者ID:alwalker,项目名称:rx_koans,代码行数:20,代码来源:Lesson4Time.cs


注:本文中的Subject.Throttle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。