本文整理汇总了C#中WorkerThread.Enqueue方法的典型用法代码示例。如果您正苦于以下问题:C# WorkerThread.Enqueue方法的具体用法?C# WorkerThread.Enqueue怎么用?C# WorkerThread.Enqueue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkerThread
的用法示例。
在下文中一共展示了WorkerThread.Enqueue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_dequeue_all_when_disposing
public void Should_dequeue_all_when_disposing()
{
var worker = new TestProcessor();
var target = new WorkerThread<int>("test", TimeSpan.FromDays(1), worker.Process);
target.Enqueue(1);
target.Enqueue(2);
target.Enqueue(3);
target.Dispose();
worker.Logs.Should().Have.SameSequenceAs(new[] {
"1, 2, 3"
});
}
示例2: Should_be_able_to_dispose_failing_worker
public void Should_be_able_to_dispose_failing_worker()
{
var worker = new TestProcessor();
var target = new WorkerThread<int>("test", TimeSpan.FromDays(1), worker.Process);
target.Enqueue(1);
target.Dispose();
worker.Logs.Should().Have.SameSequenceAs(new[] {
"1"
});
}
示例3: Should_dequeue_in_batch
public void Should_dequeue_in_batch()
{
var worker = new TestProcessor();
var target = new WorkerThread<int>("test", TimeSpan.FromSeconds(.75), worker.Process);
target.Enqueue(1);
target.Enqueue(2);
target.Enqueue(3);
worker.Go.WaitOne();
target.Enqueue(4);
target.Enqueue(5);
target.Enqueue(6);
worker.Go.WaitOne();
worker.Logs.Should().Have.SameSequenceAs(new[] {
"1, 2, 3",
"4, 5, 6"
});
}