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


C# Waiter.Wait方法代码示例

本文整理汇总了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);
			}
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:11,代码来源:MessageConsumerTest.cs

示例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);
			}
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:12,代码来源:MessageConsumerTest.cs

示例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)); 
			}
		}
开发者ID:sbcfwebdev,项目名称:Target-Process-Plugins,代码行数:14,代码来源:MessageRouterTest.cs

示例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)");
			}
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:14,代码来源:MessageConsumerTest.cs

示例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));
			}
		}
开发者ID:sbcfwebdev,项目名称:Target-Process-Plugins,代码行数:18,代码来源:MessageRouterTest.cs


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