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


C# Scheduler.Stop方法代码示例

本文整理汇总了C#中Scheduler.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# Scheduler.Stop方法的具体用法?C# Scheduler.Stop怎么用?C# Scheduler.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scheduler的用法示例。


在下文中一共展示了Scheduler.Stop方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ItShouldStartAndStopWithoutExceptions

 public void ItShouldStartAndStopWithoutExceptions()
 {
     var scheduler = new Scheduler(new FakeLoggerFactory());
     scheduler.Start();
     var stopped = scheduler.Stop().Wait(4000);
     Assert.True(stopped);
 }
开发者ID:loudej,项目名称:coral,代码行数:7,代码来源:SchedulerTests.cs

示例2: PostShouldThrowExceptionAfterStop

 public void PostShouldThrowExceptionAfterStop()
 {
     var scheduler = new Scheduler(new FakeLoggerFactory());
     scheduler.Start();
     scheduler.Stop();
     Assert.Throws<InvalidOperationException>(() => scheduler.Post("testing", () => { }));
 }
开发者ID:loudej,项目名称:coral,代码行数:7,代码来源:SchedulerTests.cs

示例3: CancelOperations_Success

		public void CancelOperations_Success()
		{
			Scheduler<CancellableScheduledAction> scheduler = new Scheduler<CancellableScheduledAction>(TimeSpan.FromSeconds(0.1));
			CancellableScheduledAction action1 = new CancellableScheduledAction();
			scheduler.Tasks.Add(new ScheduledTask<CancellableScheduledAction>(Schedule.CreateInterval(DateTimeOffset.Now, TimeSpan.FromMilliseconds(100.0), Weekdays.All), action1, true, null, null));
			CancellableScheduledAction action2 = new CancellableScheduledAction();
			scheduler.Tasks.Add(new ScheduledTask<CancellableScheduledAction>(Schedule.CreateInterval(DateTimeOffset.Now, TimeSpan.FromMilliseconds(200.0), Weekdays.All), action2, true, null, null));
			scheduler.Start();

			ManualResetEvent.WaitAny(new WaitHandle[] { action1.Waiter, action2.Waiter });
			Stopwatch watch = Stopwatch.StartNew();
			scheduler.Stop();
			Assert.IsTrue(watch.ElapsedMilliseconds < 200);
			scheduler.Dispose();
		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.Scheduler,代码行数:15,代码来源:SchedulerTest.cs

示例4: RunBot

        private static void RunBot()
        {
            try
            {
                var scheduler = new Scheduler();

                var container = CreateCompositionContainer();
                // Add all the sprockets to the sprocket list
                var announcements = container.GetExportedValues<IAnnounce>();

                Console.WriteLine(String.Format("Connecting to {0}...", _serverUrl));
                Bot bot = new Bot(_serverUrl, _botName, _botPassword);

                foreach (var s in container.GetExportedValues<ISprocket>())
                    bot.AddSprocket(s);

                bot.PowerUp();
                JoinRooms(bot);
                var users = bot.GetUsers(bot.Rooms.First());
                var user = bot.GetUserInfo(bot.Rooms.First(), users.First().Name.ToString());

                scheduler.Start(announcements, bot);

                Console.Write("Press enter to quit...");
                Console.ReadLine();

                scheduler.Stop();
                bot.ShutDown();

                _appShouldExit = true;
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: " + e.GetBaseException().Message);
            }
        }
开发者ID:Raion,项目名称:jibbr,代码行数:36,代码来源:Program.cs

示例5: Disposed_Error

		public void Disposed_Error()
		{
			Scheduler<BlockingScheduledAction> scheduler = new Scheduler<BlockingScheduledAction>();
			scheduler.Tasks.Add(new ScheduledTask<BlockingScheduledAction>(Schedule.CreateOneTime(DateTimeOffset.Now), new BlockingScheduledAction(), true, null, null));
			scheduler.Start();
			scheduler.Start();

			scheduler.Dispose();
			scheduler.Dispose();
			scheduler.Stop();

			CustomAssert.ThrowsException<ObjectDisposedException>(() =>
			{
				int i = scheduler.Tasks.Count;
			});
		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.Scheduler,代码行数:16,代码来源:SchedulerTest.cs

示例6: TaskStarting_Canceled_Success

		public void TaskStarting_Canceled_Success()
		{
			bool TaskStartingExecuted = false;
			Scheduler<BlockingScheduledAction> scheduler = new Scheduler<BlockingScheduledAction>(TimeSpan.FromSeconds(0.1));
			scheduler.TaskStarting += (sender, e) =>
			{
				e.Cancel = true;
				TaskStartingExecuted = true;
			};
			BlockingScheduledAction action1 = new BlockingScheduledAction();
			ScheduledTask<BlockingScheduledAction> task = new ScheduledTask<BlockingScheduledAction>(Schedule.CreateOneTime(DateTimeOffset.Now), action1, true, null, null);
			scheduler.Tasks.Add(task);
			scheduler.Start();

			SpinWait.SpinUntil(() => { return TaskStartingExecuted; });
			scheduler.Stop();

			Assert.IsNull(task.LastEndTime);

			scheduler.Dispose();
		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.Scheduler,代码行数:21,代码来源:SchedulerTest.cs

示例7: TaskStarting_TaskCompleted_Success

		public void TaskStarting_TaskCompleted_Success()
		{
			bool TaskStartingExecuted = false;
			bool TaskCompletedExecuted = false;
			Scheduler<BlockingScheduledAction> scheduler = new Scheduler<BlockingScheduledAction>(TimeSpan.FromSeconds(0.1));
			scheduler.TaskCompleted += (sender, e) =>
			{
				TaskCompletedExecuted = true;
			};
			scheduler.TaskStarting += (sender, e) =>
			{
				TaskStartingExecuted = true;
			};
			BlockingScheduledAction action1 = new BlockingScheduledAction();
			scheduler.Tasks.Add(new ScheduledTask<BlockingScheduledAction>(Schedule.CreateOneTime(DateTimeOffset.Now), action1, true, null, null));
			scheduler.Start();

			action1.Waiter.WaitOne();
			scheduler.Stop();

			Assert.IsTrue(TaskCompletedExecuted, nameof(TaskCompletedExecuted));
			Assert.IsTrue(TaskStartingExecuted, nameof(TaskStartingExecuted));

			scheduler.Dispose();
		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.Scheduler,代码行数:25,代码来源:SchedulerTest.cs

示例8: Stop_TimeoutExpired_Error

		public void Stop_TimeoutExpired_Error()
		{
			Scheduler<WaitingScheduledAction> scheduler = new Scheduler<WaitingScheduledAction>(TimeSpan.FromSeconds(0.1));
			WaitingScheduledAction action1 = new WaitingScheduledAction();
			scheduler.Tasks.Add(new ScheduledTask<WaitingScheduledAction>(Schedule.CreateOneTime(DateTimeOffset.Now), action1, true, null, null));
			scheduler.Start();

			action1.StartWaiter.WaitOne();
			CustomAssert.ThrowsException<CodedTimeoutException>(() =>
			{
				scheduler.Stop(TimeSpan.FromSeconds(0.5));
			});
			action1.Waiter.Set();
			scheduler.Dispose();
		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.Scheduler,代码行数:15,代码来源:SchedulerTest.cs

示例9: Stop_TimeoutNegative_Error

		public void Stop_TimeoutNegative_Error()
		{
			Scheduler<CancellableScheduledAction> scheduler = new Scheduler<CancellableScheduledAction>(TimeSpan.FromSeconds(0.1));
			scheduler.Stop();
			scheduler.Start();

			CustomAssert.ThrowsException<CodedArgumentOutOfRangeException>(() =>
			{
				scheduler.Stop(TimeSpan.FromSeconds(-1.0));
			});
			scheduler.Dispose();
		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.Scheduler,代码行数:12,代码来源:SchedulerTest.cs


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