Task 类代表异步操作,使用Task可以方便的实现CPU消耗操作的同步或者异步操作。
public static Task<IList<Task>> TrackedSequence(this TaskFactory factory, params Func<Task> [] functions)
public Task ContinueWhenAll<TAntecedentResult>(Task<TAntecedentResult>[] tasks, Action<Task<TAntecedentResult>[]> continuationAction);
Task 意味着可以不用自己定义线程,直接就能够进行异步操作。
Func 和 Action 的区别很简单,Func 是有返回值的委托, Action 是没有返回值的委托。
Func 通常用在LINQ;
list.Select(x=>x.SomeProperty)
或者过滤:
list.Where(x=>x.SomeValue==someOtherValue)
或者 key selection:
list.Join(otherList, x=>x.FirstKey, y=>y.SecondKey,...)
Action 通常用在 List<T>.ForEach 之类的。为每个 item 执行给定动作。可以用无参数的 Action 来执行类似: Control.BeginInvoke 或者 Dispatcher.BeginInvoke.
Predicate 实际上是 Func<T, bool> 的一个特例。
原文:http://blog.csdn.net/zhongshijunacm/article/details/20302495