我有類似下面的代碼:高精度定時器對象超時
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類](http://msdn.microsoft.com/en-us/library/system.threading.readerwriterlockslim.aspx)的原因? – dtb 2013-04-23 10:51:29
@dtb:不支持命名鎖。 – c00000fd 2013-04-23 22:37:42