Create a completed Task

前端 未结 8 1938
名媛妹妹
名媛妹妹 2020-11-28 06:13

I want to create a completed Task (not Task). Is there something built into .NET to do this?

A related question: Create a complete

8条回答
  •  情歌与酒
    2020-11-28 07:05

    For .Net 4.6 and above use

    return Task.CompletedTask;
    

    For lower version you can use

    return new Task(() => { });
    

提交回复
热议问题