Wait for a while without blocking main thread

前端 未结 8 1018
慢半拍i
慢半拍i 2020-12-01 20:50

I wish my method to wait about 500 ms and then check if some flag has changed. How to complete this without blocking the rest of my application?

8条回答
  •  醉话见心
    2020-12-01 21:08

    You can use await Task.Delay(500); without blocking the thread like Sleep does, and with a lot less code than a Timer.

提交回复
热议问题