kernel32.dll Sleep和Thread.Sleep()之间的任何区别 [英] Any difference between kernel32.dll Sleep and Thread.Sleep()

查看:463
本文介绍了kernel32.dll Sleep和Thread.Sleep()之间的任何区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下各项之间是否有任何区别(性能,实现...什么):

i)

DllImport("kernel32.dll")]
        public extern static void Sleep(uint msec);

..然后调用睡眠功能

ii)

Thread.Sleep()

解决方案

实际上有很大的区别.

此博客文章解释了为什么要进行托管如果可能的话,线程永远不要进行非托管阻塞. 官方MSDN文档具有相同的准则,但没有所有基本细节./p>

P.S.

..then call Sleep function

ii)

Thread.Sleep()

解决方案

There's a big difference, actually.

This blog post explains why managed threads should never do unmanaged blocking, if possible. The official MSDN documentation has the same guideline without all the underlying details.

P.S. Thread.Sleep is a sign of a poorly-designed program.

这篇关于kernel32.dll Sleep和Thread.Sleep()之间的任何区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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