ManualResetEvent WaitOne(timeout) 提前返回.任何想法为什么? [英] ManualResetEvent WaitOne(timeout) returns early. Any ideas why?

查看:51
本文介绍了ManualResetEvent WaitOne(timeout) 提前返回.任何想法为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ManualResetEvent WaitOne(timeout) 方法并将超时值设置为 30 毫秒.

I'm using the ManualResetEvent WaitOne(timeout) method and set the timeout value to 30ms.

我在 WaitOne 的任一侧使用 log4net 登录.日志消息显示 WaitOne 在仅等待 22 毫秒后返回 false.什么会导致这种情况?.Net 错误?

I log using log4net at either side of the WaitOne. The log messages show the WaitOne returned false after only waiting for 22ms. What would cause this? A .Net bug?

提前致谢.

推荐答案

来自关于 .NET 方法最终使用的等待函数的 Win32 文档 (http://msdn.microsoft.com/en-us/library/ms687069.aspx):

From the Win32 documentation on Wait Functions which the .NET methods ultimately use (http://msdn.microsoft.com/en-us/library/ms687069.aspx):

等待函数和超时间隔

指定超时的准确度间隔取决于分辨率系统时钟.系统时钟以恒定速率滴答".如果超时间隔小于系统时钟的分辨率等待可能会在少于指定的时间长度.如果超时间隔大于 1勾选但少于两个,等待可以在一到两个刻度之间的任何地方,等等.

The accuracy of the specified time-out interval depends on the resolution of the system clock. The system clock "ticks" at a constant rate. If the time-out interval is less than the resolution of the system clock, the wait may time out in less than the specified length of time. If the time-out interval is greater than one tick but less than two, the wait can be anywhere between one and two ticks, and so on.

这篇关于ManualResetEvent WaitOne(timeout) 提前返回.任何想法为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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