本文整理汇总了C#中ITask.End方法的典型用法代码示例。如果您正苦于以下问题:C# ITask.End方法的具体用法?C# ITask.End怎么用?C# ITask.End使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITask
的用法示例。
在下文中一共展示了ITask.End方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: manageTask
private void manageTask(ITask value)
{
StartingTask.Raise(this, new TaskmanagerEventArgs() { Task = value });
TaskEntry entry;
if (QueuedTasks.TryGetValue(value.UniqueId, out entry))
{
if (entry.State == "pending")
{
Exception exception = null;
try
{
CurrentTasks.TryAdd(value.UniqueId, value);
TaskEntry s;
QueuedTasks.TryRemove(value.UniqueId, out s);
StartedTask.Raise(this, new TaskmanagerEventArgs() { Task = value });
value.Run();
}
catch (Exception ex)
{
exception = ex;
Log.Error(ex.ToString());
TaskEntry s;
QueuedTasks.TryRemove(value.UniqueId, out s);
s.State = "error";
s.Message = ex.ToString() + "\n " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString();
s.UniqueId = value.UniqueId;
s.Description = value.TaskDescription; ;
s.Name = value.Name;
s.TimeStamp = value.TimeStamp;
ProcessedTasks.TryAdd(s.UniqueId, s);
ITask irt;
CurrentTasks.TryRemove(s.UniqueId, out irt);
}
finally
{
var ea = new TaskmanagerEventArgs() { Task = value, Exception = exception };
EndingTask.Raise(this, ea);
TaskEntry s;
QueuedTasks.TryRemove(value.UniqueId, out s);
s.State = "completed";
s.Message = "Completed on: " + DateTime.Now.ToString();
s.UniqueId = value.UniqueId;
s.Name = value.Name;
s.Description = value.TaskDescription;
s.TimeStamp = value.TimeStamp;
ProcessedTasks.TryAdd(s.UniqueId, s);
ITask irt;
CurrentTasks.TryRemove(s.UniqueId, out irt);
if (exception == null)
value.End();
EndedTask.Raise(this, ea);
value.Dispose();
}
}
else
{
TaskEntry s;
QueuedTasks.TryRemove(value.UniqueId, out s);
ProcessedTasks.TryAdd(s.UniqueId, s);
value.Cancel();
}
}
}
示例2: 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
}