Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
495 views
in Technique[技术] by (71.8m points)

c# - Task status WaitingForActivation - what does this mean?

I am starting wpf tasks with the way below

var newTask = Task.Factory.StartNew(() =>
{
fcStartSubPageCrawl(srMainSiteURL, srMainSiteId);
}).ContinueWith((t) =>
{
  var aggException = t.Exception.Flatten();
 foreach (var exception in aggException.InnerExceptions)
   csPages.LogException(exception.ToString());
},
TaskContinuationOptions.OnlyOnFaulted);

Now when i check the task status

like this (new tasks assigned to task list) :

  if (tskLocalTaskList[i].IsCompleted == false)

I am seeing that task status = WaitingForActivation

what does this mean ? And why it is waiting activation ?

C# 4.0 WPF

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

WaitingForActivation is the time the task resides between a call to the Start method and the moment in which the task gets scheduled by the Task scheduler. So directly after a call to the start method of a task, the tasks status is being set to WaitingForActivation and a call to scheduler.AddWork is made. In here, the Task is either scheduler (WaitingToRun) or run immidiatly.

Oh, and this has nothing to do with WPF, Tasks are a part of the BCL


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...