本文整理汇总了C#中ITask.Begin方法的典型用法代码示例。如果您正苦于以下问题:C# ITask.Begin方法的具体用法?C# ITask.Begin怎么用?C# ITask.Begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITask
的用法示例。
在下文中一共展示了ITask.Begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoCurrentTask
/// <summary>
///
/// </summary>
/// <param name="current"></param>
private void DoCurrentTask(ITask current)
{
TaskStatus status = current.Check();
switch (status)
{
case TaskStatus.Ready:
{
ICommuniPort cp = GetCommuniPort(current);
if ((cp != null) &&
(!cp.IsOccupy))
//IsHighestLevel(headTask, cp))
{
current.Begin(cp);
}
}
break;
case TaskStatus.Executing:
break;
case TaskStatus.Timeout:
{
ICommuniPort cp = GetCommuniPort(current);
current.End(cp);
DoCurrentTask(current);
}
break;
case TaskStatus.Executed:
{
IParseResult pr = current.LastParseResult;
ITaskProcessor processor = GetTaskProcessor(current);
processor.Process(current, pr);
DoCurrentTask(current);
}
break;
case TaskStatus.Wating:
{
ClearDeviceCurrentTask(current);
IDevice device = current.Device;
device.TaskManager.Tasks.Enqueue(current);
}
break;
case TaskStatus.Completed:
{
// clear current task
//
// current may not equal to current.Device.TaskManager.Current
// so an other executing task will be remove
//
ClearDeviceCurrentTask(current);
}
break;
default:
{
//
// clear
//
throw new NotSupportedException(status.ToString());
}
}
#if DEBUG
if (current.Strategy is CycleStrategy)
{
if (current.Device.TaskManager.Current == null)
{
bool b = current.Device.TaskManager.Tasks.Contains(current);
Debug.Assert(b == true);
}
}
#endif
}
示例2: DoNotExecutingTask
/// <summary>
///
/// </summary>
/// <param name="headTask"></param>
/// <returns></returns>
private bool DoNotExecutingTask(ITask headTask)
{
TaskStatus status = headTask.Check();
if (status == TaskStatus.Ready)
{
ICommuniPort cp = GetCommuniPort(headTask);
if ((cp != null) &&
(!cp.IsOccupy) &&
IsHighestLevel(headTask, cp))
{
IDevice device = headTask.Device;
headTask.Begin(cp);
device.TaskManager.Current = headTask;
return true;
}
}
return false;
}