Cha*_*mon 1 c# asynchronous task
我想知道如何使用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) );
Run Code Online (Sandbox Code Playgroud)
错误:
Error 81 Delegate 'System.Action<System.Threading.Tasks.Task<int>>' does not take 0 arguments
Run Code Online (Sandbox Code Playgroud)
Task<int> first_task = GetFirstTask();
Action<int> next_action = (result_from_first) => { //do stuff };
first_task.ContinueWith( first => next_action(first.Result) );
Run Code Online (Sandbox Code Playgroud)
应该这样做
| 归档时间: |
|
| 查看次数: |
1165 次 |
| 最近记录: |