Observé en System.Threading.TimerBase.Dipose()
que el método tiene un bloque try{} finally{}
pero el try{}
está vacío.¿Por qué usar try {} finally {} con un bloque try vacío?
¿Hay algún valor en usar try{} finally{}
con un intento vacío?
[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;
}
¿Qué hay para conseguir? ¿No leíste el útil comentario? – ChaosPandion