我正在使用 ManualResetEvent WaitOne(timeout) 方法并将超时值设置为 30 毫秒。
我在 WaitOne 的任一侧使用 log4net 登录。日志消息显示 WaitOne 在仅等待 22 毫秒后返回 false。什么会导致这个? .Net 错误?
提前致谢。
最佳答案
来自 .NET 方法最终使用的等待函数的 Win32 文档 (http://msdn.microsoft.com/en-us/library/ms687069.aspx):
Wait Functions and Time-out Intervals
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.
关于c# - ManualResetEvent WaitOne(timeout) 提前返回。任何想法为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3961795/