[threadpool] Do not swallow exception in RegisterWaitForSingleObject callback (#4408)
[mono.git] / mcs / class / corlib / System.Threading / RegisteredWaitHandle.cs
index 960ecf6e7b857595371308d71456e4c2fe0dad93..3bd11264b1a8fd04c929d3e03b624fb743621c0b 100644 (file)
@@ -98,17 +98,16 @@ namespace System.Threading
 
                private void DoCallBack (object timedOut)
                {
-                       if (_callback != null) {
-                               try {
-                                       _callback (_state, (bool)timedOut); 
-                               } catch {}
-                       }
-
-                       lock (this) 
-                       {
-                               _callsInProcess--;
-                               if (_unregistered && _callsInProcess == 0 && _finalEvent != null)
-                                       NativeEventCalls.SetEvent (_finalEvent.SafeWaitHandle);
+                       try {
+                               if (_callback != null)
+                                       _callback (_state, (bool)timedOut);
+                       } finally {
+                               lock (this)
+                               {
+                                       _callsInProcess--;
+                                       if (_unregistered && _callsInProcess == 0 && _finalEvent != null)
+                                               NativeEventCalls.SetEvent (_finalEvent.SafeWaitHandle);
+                               }
                        }
                }