[英]C# Task.continuewith that's dependent on previous Task.Result
我想知道您將如何使用Task.ContinueWith()方法來調用Action,其中int是第一個任務的結果。 這是相同的代碼示例:
Task<int> first_task = GetFirstTask();
Action<int> next_action = (result_from_first) => { //do stuff };
first_task.ContinueWith( () => next_action(first_task.Result) );
錯誤:
Error 81 Delegate 'System.Action<System.Threading.Tasks.Task<int>>' does not take 0 arguments
Task<int> first_task = GetFirstTask();
Action<int> next_action = (result_from_first) => { //do stuff };
first_task.ContinueWith( first => next_action(first.Result) );
應該做
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.