Thread.Sleep replacement in .NET for Windows Store

后端 未结 5 2040
逝去的感伤
逝去的感伤 2020-11-30 21:34

Thread.Sleep doesn\'t seem to be supported in .NET for Windows Store apps.

For example, this

System.Threading.Thread.Sleep(1000);

5条回答
  •  遥遥无期
    2020-11-30 22:06

    There is almost NO reason (except for testing purposes) to EVER use Thread.Sleep().

    IF (and only if) you have a very good reason to send a thread to sleep, you might want to check Task.Delay() , which you can await to "wait" for a specified time. Though it's never a good idea to have a thread sitting around and do nothing. Bad practise ...

提交回复
热议问题