本文整理汇总了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();
});
}
示例2: Dispose_Error
public void Dispose_Error()
{
Scheduler<WaitingScheduledAction>.CancellationTokenSchedulerAction action = new Scheduler<WaitingScheduledAction>.CancellationTokenSchedulerAction();
action.Dispose();
action.Dispose();
CustomAssert.ThrowsException<ObjectDisposedException>(() =>
{
action.ThrowIfCancellationRequested();
});
}
示例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();
}
示例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();
}
示例5: ThrowIfCancellationRequested_Success
public void ThrowIfCancellationRequested_Success()
{
Scheduler<WaitingScheduledAction>.CancellationTokenSchedulerAction action = new Scheduler<WaitingScheduledAction>.CancellationTokenSchedulerAction();
action.ThrowIfCancellationRequested();
}