本文整理汇总了C#中ITask.Update方法的典型用法代码示例。如果您正苦于以下问题:C# ITask.Update方法的具体用法?C# ITask.Update怎么用?C# ITask.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITask
的用法示例。
在下文中一共展示了ITask.Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
/// <summary>
/// Processes the task based on its current state.
/// </summary>
/// <remarks>
/// <para>
/// Only performs a single action per call. So it will always take multiple calls for a
/// task to be fully processed.
/// </para>
/// <para>
/// The <paramref name="failure"/> flag indicates whether the task is in a failed state.
/// (Note: It may still need processing.)
/// </para>
/// </remarks>
/// <param name="task">The behaivor to process.</param>
/// <param name="failure">True if the task is detected in a failed state.</param>
/// <returns>True if the task needs more processing.</returns>
public static bool Process(AgentContext context, ITask task, out bool failure)
{
failure = false;
switch (task.State)
{
case TaskState.Active:
task.Update(context);
return true;
case TaskState.Complete:
return !task.Exit(context);
case TaskState.Exiting:
return !task.Exit(context);
case TaskState.Failed:
failure = true;
return !task.Exit(context);
case TaskState.Inactive:
task.Update(context);
return true;
}
return true;
}
示例2: ProcessImmediate
/// <summary>
/// Processes the task based on its current state, optimized to complete the task more
/// quickly.
/// </summary>
/// <remarks>
/// <para>
/// The exit process will be triggered as soon as completion is dectected. So this
/// method may perform two operations (update and exit) in a single call.
/// </para>
/// </remarks>
/// <param name="task">The task to process.</param>
/// <returns>True if the task needs more processing.</returns>
public static bool ProcessImmediate(AgentContext context, ITask task)
{
switch (task.State)
{
case TaskState.Active:
if (IsFinished(task.Update(context)))
return !task.Exit(context);
return true;
case TaskState.Complete:
return !task.Exit(context);
case TaskState.Exiting:
return !task.Exit(context);
case TaskState.Failed:
return !task.Exit(context);
case TaskState.Inactive:
if (IsFinished(task.Update(context)))
return !task.Exit(context);
return true;
}
return true;
}