Reduce TLS accesses. (#11487)
[mono-project.git] / mono / tests / threadpool-exceptions7.cs
blob1ca97467a71fe0f8d6cb5c26e2c9177043eb0760
1 using System;
2 using System.Threading;
4 class Test {
5 static int Main ()
7 AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
8 OtherDomain ();
9 return 0;
12 static void OtherDomain ()
14 AppDomain domain = AppDomain.CreateDomain ("test");
15 ThreadPool.QueueUserWorkItem (unused => {
16 domain.DoCallBack (() => {
17 AppDomain.CurrentDomain.SetData ("key", "checked");
19 // This will get a ThreadAbortedException
20 Thread.Sleep (10000);
21 });
22 });
24 if (!SpinWait.SpinUntil (() => domain.GetData ("key") as string == "checked", 10000))
25 Environment.Exit (4);
27 AppDomain.Unload (domain);
30 static void OnUnhandledException (object sender, UnhandledExceptionEventArgs e)
32 Environment.Exit (3);