Explicitly use a Func for asynchronous lambda function when Action overload is available

前端 未结 4 1097
死守一世寂寞
死守一世寂寞 2020-12-13 17:38

Reading over this blog post on some of the gotchas of C#5\'s async/await. It mentions in Gotcha #4 something that is quite profound and that I hadn\'t thought of before.

4条回答
  •  忘掉有多难
    2020-12-13 18:15

    There is a nice Roslyn analyzer from Microsoft team.

    This analyzer helps prevent inadvertent creation of async void delegates.

    https://github.com/Microsoft/vs-threading/blob/master/doc/analyzers/VSTHRD101.md

提交回复
热议问题