本文整理汇总了C#中Subject.Buffer方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.Buffer方法的具体用法?C# Subject.Buffer怎么用?C# Subject.Buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject.Buffer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BufferedHandler
public BufferedHandler(TimeSpan timeDelay, int batchSize)
{
_storiesSubject = new Subject<IStory>();
_storiesSubject.Buffer(timeDelay, batchSize)
.Where(buffer => buffer.Any())
.Subscribe(OnStoriesComplete, OnComplete);
}
示例2: BufferedHandler
protected BufferedHandler(string name, TimeSpan timeDelay, int batchSize)
: base(name)
{
_storiesSubject = new Subject<IStory>();
_storiesSubject.Buffer(timeDelay, batchSize)
.Where(buffer => buffer.Any())
.Subscribe(OnStoriesComplete, OnComplete);
}
示例3: Buffering
public void Buffering()
{
var received = new List<String>();
var events = new Subject<char>();
events.Buffer(TimeSpan.FromMilliseconds(100)).Select(c => new String(c.ToArray())).Subscribe(s => received.Add(s));
events.OnNext('S');
events.OnNext('c');
events.OnNext('o');
events.OnNext('t');
events.OnNext('t');
Thread.Sleep(120);
events.OnNext('R');
events.OnNext('e');
events.OnNext('e');
events.OnNext('d');
Thread.Sleep(120);
Assert.AreEqual("Scott Reed", String.Join(" ", received));
}
示例4: SetupListener
private void SetupListener()
{
messagePump = new Subject<LogMessage>();
messagePump.Buffer(TimeSpan.FromSeconds(1)).Subscribe(MessageReceivedAction);
}
示例5: BufferWindowBoundaries
public void BufferWindowBoundaries()
{
var subject = new Subject<int>();
var boundaries = new Subject<int>();
var record = subject.Buffer(boundaries).Record();
subject.OnNext(1);
subject.OnNext(2);
record.Values.Count.Is(0);
boundaries.OnNext(0);
record.Values.Count.Is(1);
record.Values[0].IsCollection(1, 2);
boundaries.OnNext(0);
record.Values.Count.Is(2);
record.Values[1].Count.Is(0);
}
示例6: BufferTimeAndCountTimeSide
public void BufferTimeAndCountTimeSide()
{
var subject = new Subject<int>();
var record = subject.Buffer(TimeSpan.FromMilliseconds(100), 100).Take(5).Record();
Thread.Sleep(TimeSpan.FromSeconds(2));
record.Values.Count.Is(5);
}
示例7: BufferWindowBoundaries
public void BufferWindowBoundaries()
{
SetScehdulerForImport();
var subject = new Subject<int>();
var boundaries = new Subject<int>();
var record = subject.Buffer(boundaries).Record();
subject.OnNext(1);
subject.OnNext(2);
record.Values.Count.Is(0);
boundaries.OnNext(0);
record.Values.Count.Is(1);
record.Values[0].IsCollection(1, 2);
boundaries.OnNext(0);
record.Values.Count.Is(2);
record.Values[1].Count.Is(0);
UniRx.Scheduler.SetDefaultForUnity();
}
示例8: BufferTimeAndCountTimeSide
public void BufferTimeAndCountTimeSide()
{
SetScehdulerForImport();
var subject = new Subject<int>();
var record = subject.Buffer(TimeSpan.FromMilliseconds(100), 100).Take(5).Record();
Thread.Sleep(TimeSpan.FromSeconds(2));
record.Values.Count.Is(5);
UniRx.Scheduler.SetDefaultForUnity();
}