Ho notato nel System.Threading.TimerBase.Dipose()
il metodo ha un blocco try{} finally{}
ma lo try{}
è vuoto.Perché usare try {} finally {} con un blocco try vuoto?
C'è qualche valore nell'uso di try{} finally{}
con una prova vuota?
[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;
}
Cosa c'è da ottenere? Non hai letto il commento utile? – ChaosPandion