本文整理汇总了C#中System.Threading.Task.nextInterval方法的典型用法代码示例。如果您正苦于以下问题:C# Task.nextInterval方法的具体用法?C# Task.nextInterval怎么用?C# Task.nextInterval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.Task
的用法示例。
在下文中一共展示了Task.nextInterval方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: add
/// <remarks>
/// <b>Relative Scheduling</b>
/// <tt>true</tt>:<br></br>
/// Task is rescheduled relative to the last time it <i>actually</i>
/// started execution
/// <p>
/// <tt>false</tt>:<br></br>
/// Task is scheduled relative to its <i>last</i> execution schedule. This
/// has the effect that the time between two consecutive executions of
/// the task remains the same.
/// </p>
/// </remarks>
/// <summary>
/// Add a task for execution at adjustable intervals
/// </summary>
/// <param name="t">The task to execute</param>
/// <param name="relative">Use relative scheduling</param>
public void add(Task t, bool relative)
{
long interval, sched;
if ((interval = t.nextInterval()) < 0) return;
sched = System.Environment.TickCount + interval;
lock(queue)
{
queue.add(new IntTask(t, sched, relative));
switch(thread_state)
{
case RUN: Monitor.PulseAll(queue); break;
case SUSPEND: _unsuspend(); break;
case STOPPING: break;
case STOP: break;
}
}
}