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


C# Scheduler.ThrowIfCancellationRequested方法代码示例

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


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

示例1: ThrowIfCancellationRequested_Error

		public void ThrowIfCancellationRequested_Error()
		{
			Scheduler<WaitingScheduledAction>.CancellationTokenSchedulerAction action = new Scheduler<WaitingScheduledAction>.CancellationTokenSchedulerAction();
			action.Cancel();

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

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

示例3: ThrowIfCancellationRequested_Success

		public async System.Threading.Tasks.Task ThrowIfCancellationRequested_Success()
		{
			ManualResetEventSlim Waiter = new ManualResetEventSlim(false);

			await ThreadPool.RunAsync(new WorkItemHandler((target) =>
			{
				Scheduler<WaitingScheduledAction>.AsyncActionSchedulerAction action = new Scheduler<WaitingScheduledAction>.AsyncActionSchedulerAction(target);
				action.ThrowIfCancellationRequested();
				Waiter.Set();
			}));

			Waiter.Wait();
		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.Scheduler,代码行数:13,代码来源:AsyncActionSchedulerActionTest.cs

示例4: ThrowIfCancellationRequested_Error

		public void ThrowIfCancellationRequested_Error()
		{
			ManualResetEventSlim StartWaiter = new ManualResetEventSlim(false);
			ManualResetEventSlim Waiter = new ManualResetEventSlim(false);
			PreallocatedWorkItem workitem = new PreallocatedWorkItem(new WorkItemHandler((target) =>
			{
				Scheduler<WaitingScheduledAction>.AsyncActionSchedulerAction action = new Scheduler<WaitingScheduledAction>.AsyncActionSchedulerAction(target);
				StartWaiter.Wait();

				CustomAssert.ThrowsException<OperationCanceledException>(() =>
				{
					action.ThrowIfCancellationRequested();
				});
				Waiter.Set();
			}));

			IAsyncAction iaa = workitem.RunAsync();
			iaa.Cancel();
			StartWaiter.Set();
			Waiter.Wait();
		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.Scheduler,代码行数:21,代码来源:AsyncActionSchedulerActionTest.cs

示例5: ThrowIfCancellationRequested_Success

		public void ThrowIfCancellationRequested_Success()
		{
			Scheduler<WaitingScheduledAction>.CancellationTokenSchedulerAction action = new Scheduler<WaitingScheduledAction>.CancellationTokenSchedulerAction();
			action.ThrowIfCancellationRequested();
		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.Scheduler,代码行数:5,代码来源:CancellationTokenSchedulerActionTest.cs


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