我注意到System.Threading.TimerBase.Dispose()
该方法中有一个try{} finally{}
块,但是try{}
为空。
try{} finally{}
与空值一起使用是否有任何价值try
?
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal bool Dispose(WaitHandle notifyObject)
{
bool status = false;
bool bLockTaken = false;
RuntimeHelpers.PrepareConstrainedRegions();
try {
}
finally {
do {
if (Interlocked.CompareExchange(ref m_lock, 1, 0) == 0) {
bLockTaken = true;
try {
status = DeleteTimerNative(notifyObject.SafeWaitHandle);
}
finally {
m_lock = 0;
}
}
Thread.SpinWait(1);
// yield to processor
}
while (!bLockTaken);
GC.SuppressFinalize(this);
}
return status;
}
周围的System.Diagnostics.Process线2144以及:referencesource.microsoft.com/#System/services/monitoring/...
—
帕特里克Artner