本文整理汇总了C#中System.Threading.Task.GetNextInterval方法的典型用法代码示例。如果您正苦于以下问题:C# Task.GetNextInterval方法的具体用法?C# Task.GetNextInterval怎么用?C# Task.GetNextInterval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.Task
的用法示例。
在下文中一共展示了Task.GetNextInterval方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTask
/// <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 AddTask(Task t, bool relative)
{
long interval;
lock(this)
{
if(thread_state == State.DISPOSED) return;
if((interval = t.GetNextInterval()) < 0) return;
queue.Push(new QueuedEvent(t));
switch(thread_state)
{
case State.RUN: break;
case State.SUSPEND: _unsuspend(); break;
case State.STOPPING: break;
case State.STOP: break;
}
}
}