本文整理汇总了C#中IObservable.Buffer方法的典型用法代码示例。如果您正苦于以下问题:C# IObservable.Buffer方法的具体用法?C# IObservable.Buffer怎么用?C# IObservable.Buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObservable
的用法示例。
在下文中一共展示了IObservable.Buffer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public IObservable<FileSystemChange> Configure(IObservable<FileSystemChange> observable)
{
// http://stackoverflow.com/questions/9985125/in-rx-how-to-group-latest-items-after-a-period-of-time
return observable.Buffer(() => observable.Throttle(TimeSpan.FromSeconds(2)).Timeout(TimeSpan.FromMinutes(1)))
.PrioritizeFileSystemChanges()
.SelectMany(x => x);
}
示例2: BulkTrigger
/// <summary>
/// Bulks the trigger.
/// </summary>
/// <param name="streamRate">The stream rate.</param>
/// <param name="scheduler">The scheduler.</param>
/// <returns></returns>
public IObservable<Unit> BulkTrigger(
IObservable<Unit> streamRate,
IScheduler scheduler)
{
var result = streamRate.Buffer(3)
.Select(_ => Unit.Default);
return result;
}
示例3: ObserveScenarioOuput
private static void ObserveScenarioOuput(IObservable<int> count)
{
count
.Sum()
.Subscribe(total => ScenarioSimulatorEventSource.Log.FinalEventCountForAllDevices(total));
count
.Buffer(TimeSpan.FromMinutes(5))
.Scan(0, (total, next) => total + next.Sum())
.Subscribe(total => ScenarioSimulatorEventSource.Log.CurrentEventCountForAllDevices(total));
count
.Buffer(TimeSpan.FromMinutes(0.1))
.TimeInterval()
.Select(x => x.Value.Sum() / x.Interval.TotalSeconds)
.Subscribe(rate => ScenarioSimulatorEventSource.Log.CurrentEventsPerSecond(rate));
}
示例4: DetectCorrectKeypass
public IObservable<bool> DetectCorrectKeypass(IObservable<string> keypresses, string password, TimeSpan delay, IScheduler scheduler)
{
return keypresses
.Buffer(delay, password.Length, scheduler)
.Select(listStr => string.Join(string.Empty, listStr.ToArray()))
.Do(guess => EnteredPassKey = guess)
.Where(guess => guess != string.Empty)
.Select(guess => guess == password)
.DistinctUntilChanged();
}
示例5: Apply
public IObservable<IEnumerable<DataPoint>> Apply(IObservable<DataPoint> dataPoints)
{
return dataPoints.Buffer(BufferSize);
}
示例6: Filter
public static IObservable<float> Filter(IObservable<float> src, int bufferSize, int dropSize, int takeSize)
{
return src.Buffer(bufferSize).Select((buffered, index) => ApplyFilter(buffered, index, dropSize, takeSize));
}