本文整理汇总了C#中Waiter.Wait方法的典型用法代码示例。如果您正苦于以下问题:C# Waiter.Wait方法的具体用法?C# Waiter.Wait怎么用?C# Waiter.Wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Waiter
的用法示例。
在下文中一共展示了Waiter.Wait方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckOrderTest
public void CheckOrderTest()
{
IMessageSource<TestMessage> source = MessageGenerator.CreateSource(TestRouterHelper.SourceName, TestRouterHelper.MessagesCountToGenerate);
var waiter = new Waiter(waitablesCount:1);
var factory = new TestRouterFactory(waiter, messages => messages.CheckOrder(TestRouterHelper.Sequence(0, TestRouterHelper.MessagesCountToGenerate)));
using(IMessageConsumer<TestMessage> consumer = factory.CreateConsumer(source))
{
consumer.Consume(TestRouterHelper.HandleMessage);
waiter.Wait(true);
}
}
示例2: SwallowExceptionTest
public void SwallowExceptionTest()
{
const int errorMessageIndex = 5;
var waiter = new Waiter(waitablesCount:1);
IMessageSource<TestMessage> source = MessageGenerator.CreateSource(TestRouterHelper.SourceName, TestRouterHelper.MessagesCountToGenerate, errorMessageIndex, swallowException:true);
var factory = new TestRouterFactory(waiter, messages => messages.CheckOrder(TestRouterHelper.SequenceExcluding(0, TestRouterHelper.MessagesCountToGenerate, errorMessageIndex)));
using (IMessageConsumer<TestMessage> consumer = factory.CreateConsumer(source))
{
consumer.Consume(TestRouterHelper.HandleMessage);
waiter.Wait(true);
}
}
示例3: ChildrenOrderTest
public void ChildrenOrderTest()
{
const int sourcesCount = 5;
IMessageSource<TestMessage> source = MessageGenerator.CreateCompositeSource(TestRouterHelper.SourceName, sourcesCount, TestRouterHelper.MessagesCountToGenerate);
var waiter = new Waiter(sourcesCount);
var factory = new TestRouterFactory(waiter, messages => messages.CheckOrder(TestRouterHelper.Sequence(0, TestRouterHelper.MessagesCountToGenerate)));
using (IMessageConsumer<TestMessage> router = factory.CreateRouter(source, factory, m => m.Tag))
{
router.Consume(TestRouterHelper.HandleMessage);
waiter.Wait(true);
// we compare to 55, not 50, because each source has stop message at the end.
((TestMessageRouter) router).ReceiveCallCount.Should(Be.EqualTo(55));
}
}
示例4: CheckIsRunningTest
public void CheckIsRunningTest()
{
IMessageSource<TestMessage> source = MessageGenerator.CreateSource(TestRouterHelper.SourceName, TestRouterHelper.MessagesCountToGenerate);
var waiter = new Waiter(waitablesCount:1);
var factory = new TestRouterFactory(waiter, messages =>{});
using (IMessageConsumer<TestMessage> consumer = factory.CreateConsumer(source))
{
consumer.IsRunning.Should(Be.False, "consumer.IsRunning.Should(Be.False)");
consumer.Consume(TestRouterHelper.HandleMessage);
consumer.IsRunning.Should(Be.True, "consumer.IsRunning.Should(Be.True)");
waiter.Wait();
consumer.IsRunning.Should(Be.True, "consumer.IsRunning.Should(Be.True)");
}
}
示例5: RouterShouldHandleMessagesIfTagIsNotProvided
public void RouterShouldHandleMessagesIfTagIsNotProvided()
{
IMessageSource<TestMessage> source = MessageGenerator.CreateSource(string.Empty, 5);
var waiter = new Waiter(1);
var factory = new TestRouterFactory(waiter, messages => { });
using (IMessageConsumer<TestMessage> router = factory.CreateRouter(source, factory, m => m.Tag))
{
var messagesHandled = 0;
waiter.Register(router);
router.While = m => TestMessage.IsNotStopMessage(string.Empty, m);
router.Consume(message => messagesHandled++);
waiter.Wait(true);
messagesHandled.Should(Be.EqualTo(6));
//Do not receive message from queue, if router handles message by itself. Let the handle logic do this.
((TestMessageRouter)router).ReceiveCallCount.Should(Be.EqualTo(0));
}
}