Getting return value from Task.Run

前端 未结 2 1008
迷失自我
迷失自我 2020-12-29 00:44

I have the following code:

public static async Task Start(IProgress progress)
{
    const int total = 10;
            


        
2条回答
  •  一个人的身影
    2020-12-29 01:25

    Remove the Result from the end. When you await you will get the Result back from the await-able method.

    var val = await Task.Run(() => RunLongTask(i.ToString(CultureInfo.InvariantCulture)));
    

提交回复
热议问题