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


C# Scheduler.Dispose方法代码示例

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


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

示例1: Dispose_Error

		public void Dispose_Error()
		{
			Scheduler<WaitingScheduledAction>.CancellationTokenSchedulerAction action = new Scheduler<WaitingScheduledAction>.CancellationTokenSchedulerAction();
			action.Dispose();
			action.Dispose();

			CustomAssert.ThrowsException<ObjectDisposedException>(() =>
			{
				action.ThrowIfCancellationRequested();
			});
		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.Scheduler,代码行数:11,代码来源:CancellationTokenSchedulerActionTest.cs

示例2: Ctor_TimeSpan_Success

		public void Ctor_TimeSpan_Success()
		{
			Scheduler<BlockingScheduledAction> scheduler = new Scheduler<BlockingScheduledAction>(TimeSpan.FromSeconds(0.1));
			BlockingScheduledAction action = new BlockingScheduledAction();
			scheduler.Tasks.Add(new ScheduledTask<BlockingScheduledAction>(Schedule.CreateOneTime(DateTimeOffset.Now.AddSeconds(1.0)), action, true, null, null));
			scheduler.Start();
			Assert.IsTrue(scheduler.IsEnabled);

			Stopwatch watch = Stopwatch.StartNew();
			action.Waiter.WaitOne();
			Assert.IsTrue(watch.ElapsedMilliseconds < 2000);
			scheduler.Dispose();
		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.Scheduler,代码行数:13,代码来源:SchedulerTest.cs

示例3: MultipleIterations_Success

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

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

示例4: 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

示例5: 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

示例6: 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

示例7: Interval_Success

		public void Interval_Success()
		{
			Scheduler<BlockingScheduledAction> scheduler = new Scheduler<BlockingScheduledAction>(TimeSpan.FromSeconds(1000.0));
			BlockingScheduledAction action1 = new BlockingScheduledAction(5);
			scheduler.Tasks.Add(new ScheduledTask<BlockingScheduledAction>(Schedule.CreateInterval(DateTimeOffset.Now, TimeSpan.FromMilliseconds(200.0), Weekdays.All), action1, true, null, null));
			scheduler.Start();

			Assert.AreEqual(1000.0, scheduler.Interval.TotalSeconds);
			scheduler.Interval = TimeSpan.FromSeconds(0.1);

			Stopwatch watch = Stopwatch.StartNew();
			action1.Waiter.WaitOne();
			Assert.IsTrue(watch.ElapsedMilliseconds < 1200);
			scheduler.Dispose();
		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.Scheduler,代码行数:15,代码来源: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.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。