2 using System
.Threading
;
5 This test stresses what happens when root domain threads are allocating into the nursery
6 while a domain is cleaned up.
8 This is a regression test for a crash in the domain object cleaner code that did not
9 stop-the-world before walking the heap.
12 static void AllocStuff ()
14 var x
= new object ();
15 for (int i
= 0; i
< 300; ++i
)
19 static void BackgroundNoise ()
26 for (int i
= 0; i
< Math
.Max (1, Environment
.ProcessorCount
/ 2); ++i
) {
27 // for (int i = 0; i < 4; ++i) {
28 var t
= new Thread (BackgroundNoise
);
29 t
.IsBackground
= true;
35 for (TestTimeout timeout
= TestTimeout
.Start(TimeSpan
.FromSeconds(TestTimeout
.IsStressTest
? 120 : 5)); timeout
.HaveTimeLeft
;) {
36 var ad
= AppDomain
.CreateDomain ("domain_" + iterations
);
37 ad
.DoCallBack (new CrossAppDomainDelegate (AllocStuff
));
38 AppDomain
.Unload (ad
);
41 if ((++iterations
) % 20 == 0) Console
.WriteLine ();
43 Console
.WriteLine ($"\ndone {iterations} iterations");