In WaitForSingleObject, is timeout=INFINITE the same as timeout=-1?

混江龙づ霸主 提交于 2019-12-11 01:19:38

问题


I'm working with some Visual Basic for Applications (VB 6.3) code written by someone else, and they've written:

WaitForSingleObject SEI.hProcess, -1

The process this appears in is supposed to return some data in a text box; sometimes it fails to return anything, and I think it's because of this, possibly because it's its timing out. Is that code the same as:

WaitForSingleObject SEI.hProcess, INFINITE

???

Thanks for your help.


回答1:


The timeout for WaitForSingleObject is actually a DWORD, which is an unsigned 32 bit integer. INFINITE is defined as 0xFFFFFFFF, but -1 mapped into an unsigned type wraps and becomes this value in most integer representations.

Is that code the same as:

Effectively, yes.



来源:https://stackoverflow.com/questions/19578949/in-waitforsingleobject-is-timeout-infinite-the-same-as-timeout-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!