async await best practices

后端 未结 3 1924
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 12:32

I\'ve grasped the concept of async await and have been using it sporadically, but do have a couple questions regarding best practices.

  1. is it ok to use await in

3条回答
  •  长情又很酷
    2021-02-06 13:10

    Good morning,

    I would rather use a regular task with the TaskCreationOption set to 'LongRunning' in your first scenario than the async/await pattern. This way your whole while block would be executed in one long running task. When using await inside each while loop you would start a new task with every loop - would work, but it's maybe not so optimal ;-)

    Regarding your second question, I'm sorry but I don't get your point.

    Hope this helps.

提交回复
热议问题