替代 Thread.Sleep 那个块 [英] Alternative to Thread.Sleep that block

查看:52
本文介绍了替代 Thread.Sleep 那个块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找调用 Thread.Sleep 的替代方法,它不会阻塞线程而是将线程返回到线程池中.这种东西存在吗?

I am looking for an alternative to calling Thread.Sleep which does not block the thread but instead returns the thread back into the thread pool. Does such a thing exist?

推荐答案

使用 任务延迟

await Task.Delay(delay);

这篇关于替代 Thread.Sleep 那个块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆