从Microsoft APIs and reference documentation,我可以读到:
public Task<TNewResult> ContinueWith<TNewResult>(
Func<Task<TResult>, TNewResult> continuationFunction
)
参数
continuationFunction
Type: System.Func<Task<TResult>, TNewResult>
任务完成时运行的函数。运行时,委托将作为参数传递完成的任务。
无法弄清楚,参数 continuationFunction 通过哪种机制引用任务。
例如:
public static Task<DateTimeOffset?> GetLastModified()
{
HttpClient theRequest = new HttpClient();
var theTask = theRequest.GetAsync("https://www.yahoo.com/news/rss");
return theTask.ContinueWith((Task<HttpResponseMessage> antecedent) => {
return antecedent.Result.Content.Headers.LastModified;
});
}
antecedent 如何与 theTask 相关联?