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);
+ }
}
}
unhandled-exception-4.exe \
unhandled-exception-5.exe \
unhandled-exception-6.exe \
- unhandled-exception-7.exe
+ unhandled-exception-7.exe \
+ unhandled-exception-8.exe
test-unhandled-exception-2: $(UNHANDLED_EXCEPTION_1_TESTS) $(UNHANDLED_EXCEPTION_255_TESTS)
$(MAKE) test-unhandled-exception-2-1-with-managed-handler
--- /dev/null
+
+using System;
+using System.Threading;
+
+class CustomException : Exception
+{
+}
+
+class Driver
+{
+ /* expected exit code: 255 */
+ public static void Main ()
+ {
+ if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
+ AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
+
+ ManualResetEvent mre = new ManualResetEvent(false);
+
+ ThreadPool.RegisterWaitForSingleObject (mre, (state, timedOut) => { throw new CustomException (); }, null, -1, true);
+ mre.Set();
+
+ Thread.Sleep (5000);
+ }
+}
\ No newline at end of file