As described on https://msdn.microsoft.com/en-us/library/system.appdomainunloadedexception(v=vs.110).aspx#Anchor_6
appdomain-unload-callback.cs \
appdomain-unload-doesnot-raise-pending-events.cs \
appdomain-unload-asmload.cs \
+ appdomain-unload-exception.cs \
unload-appdomain-on-shutdown.cs \
bug-47295.cs \
loader.cs \
# tests that expect a 1 exit code
TESTS_UNHANDLED_EXCEPTION_1_SRC = \
- unhandled-exception-1.cs
+ unhandled-exception-1.cs \
+ unhandled-exception-9.cs
# tests that expect a 255 exit code
TESTS_UNHANDLED_EXCEPTION_255_SRC = \
--- /dev/null
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+class Driver
+{
+ static void ThrowTP ()
+ {
+ ManualResetEvent mre = new ManualResetEvent (false);
+
+ ThreadPool.QueueUserWorkItem (_ => { try { throw new AppDomainUnloadedException (); } finally { mre.Set (); } });
+
+ if (!mre.WaitOne (5000))
+ Environment.Exit (1);
+
+ /* Wait for exception unwinding */
+ Thread.Sleep (500);
+ }
+
+ static void ThrowThread ()
+ {
+ Thread thread = new Thread (_ => { throw new AppDomainUnloadedException (); });
+ thread.Start ();
+ thread.Join ();
+ }
+
+ static int Main (string[] args)
+ {
+ ThrowTP ();
+ ThrowThread ();
+
+ return 0;
+ }
+}
--- /dev/null
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+class Driver
+{
+ /* expected exit code: 1 */
+ static void Main (string[] args)
+ {
+ if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
+ AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
+
+ throw new AppDomainUnloadedException ();
+ }
+}