【发布时间】:2013-04-23 10:46:02
【问题描述】:
我有类似下面的代码:
public void acquireReaderLock(int nmsMaxWait)
{
//'nmsMaxWait' = timeout in milliseconds
if(_mutex.WaitOne(nmsMaxWait))
{
//Need time left for the second wait?
if(_semaphore.WaitOne(???)
{
}
else
throw new Exception("Timed out");
}
else
throw new Exception("Timed out");
}
我正在寻找一个高精度计时器。在 C++ 中,我会使用 GetTickCount 或 GetSystemTimeAsFileTime API 来测量经过的时间,但我应该在 C# 中使用什么?
【问题讨论】:
-
您不使用ReaderWriterLockSlim Class的任何原因?
-
@dtb:不支持命名锁。