8.2.Task

  1. Task.Run()
    StackCrawlMark stackMark=StackCrawlMark.LookForMyCaller;
    return Task.InternalStartNew(null,action,null,default(CancellationToken),TaskScheduler.Default,TaskCreationOptions.DenyChildAttach,InternalTaskOptions.None,ref stackMark);

  2. Task.Factory
    private readonly static TaskFactory s_factory=new TaskFactory();
    return s_factory;

  3. TaskFactory.StartNew()
    StackCrawlMark stackMark=StackCrawlMark.LookForMyCaller;
    Task currTask=Task.InternalCurrent;
    return Task.InternalStartNew(currTask,action)

  4. TaskFactory.GetDefaultScheduler(Task currTask)
    if(m_defaultScheduler!=null)return m_defaultScheduler;
    return currTask.ExecutingTaskScheduler;
    return TaskScheduler.Default;

Task.cs 7309行

1. internal class Shared

2. public enum TaskStatus

1. created   //已创建没有列入计划执行
2. waitingForActivation     //等待.net加入加入计划
3. waitingToRun             //已列入计划,但是还未执行
4. running                  //正在执行但是没有激素
5. waitingforchildrentocomplete   //任务执行完毕,隐式等待子任务的完成
6. runtocompletion  //任务全部顺利执行完毕
7. canceled         //手动跑出OperationCanceledException 异常停止task
8. faulted          //发生任何异常导致任务结束

3. Task

4. internal class SystemThreadingTasks_TaskDebugView

5. internal class ParallerForReplicatingTask

6. internal class ParallerForReplicaTask

7. public enum TaskCreationOptions

1. None
2. PreferFairness
3. LongRunning
4. AttachedToParent
5. DenyChildAttach
6. HideScheduler
7. RunContinuationsAsynchronously

8. public enum InternalTaskOptions

9. public enum TaskCountinuationOptions

10. internal class StackGuard

posted @ 2017-10-19 21:41  给我一个理由  阅读(66)  评论(0编辑  收藏