## 组合ContinueWith

  public static void Main()
{
//创建一个任务
{
int sum = 0;
for (int i = 0; i <= 100; i++)
{
sum += i;
}
return sum;
});

Console.WriteLine("主線程執行其他程序.");

//任务完成时执行处理。
{
Console.WriteLine("任務完成後的結果是：{0}", t.Result.ToString());
});
cwt.Wait();
}

      static void Main(string[] args)
{
ConcurrentStack<int> stack = new ConcurrentStack<int>();

//t1先串行
{
//入棧
stack.Push(1);
stack.Push(2);
});

//t2,t3并行执行
var t2 = t1.ContinueWith(t =>
{
int result;
//出棧
stack.TryPop(out result);
});

//t2,t3并行执行
var t3 = t1.ContinueWith(t =>
{
int result;
//出棧
stack.TryPop(out result);
});

//等待t2和t3执行完

//t7串行执行
{
});
t4.Wait();
}

   public static void Main()
{
{
Console.WriteLine(state);
string[] result = new string[2];
//创建并启动子任务
return result;
}, "我是父任務，並在處理過程中創建多個子任務，所有的子任務完成以後我才會開始執行。");
//任务处理完成后执行的操作
parent.ContinueWith(t =>
{
Array.ForEach(t.Result, r => Console.WriteLine(r));
});
//启动父任务
parent.Start();
//等待任务结束 Wait只能等待父线程结束,没办法等到父线程的ContinueWith结束
//parent.Wait();

}

  class Node
{
public Node Left { get; set; }
public Node Right { get; set; }
public string Text { get; set; }
}
class Program
{
static Node GetNode()
{
Node root = new Node
{
Left = new Node
{
Left = new Node
{
Text = "L-L"
},
Right = new Node
{
Text = "L-R"
},
Text = "L"
},
Right = new Node
{
Left = new Node
{
Text = "R-L"
},
Right = new Node
{
Text = "R-R"
},
Text = "R"
},
Text = "Root"
};
return root;
}

static void Main(string[] args)
{
Node root = GetNode();
DisplayTree(root);
}

static void DisplayTree(Node root)
{
CancellationToken.None,
}

static void DisplayNode(Node current)
{

if (current.Left != null)
CancellationToken.None,
if (current.Right != null)
CancellationToken.None,
}