[System.ServiceModel] Prevent crash in Dispatcher.ListenerLoopManager… (#7136)
[mono-project.git] / mono / tests / sgen-suspend.cs
blob10581fe9d0b3fe4fd58b769ec1e1ae34c57aaf7a
1 using System;
2 using System.Threading;
4 /*
5 This test stresses the interaction of the multiple suspend sources and stop-the-world.
7 Right now the current iteraction that we stresses is between the domain unloader and
8 sgen STW. It's mighty hard to get this right on mach.
9 */
11 class Driver {
13 static void AllocStuff ()
15 var x = new object ();
16 for (int i = 0; i < 300; ++i)
17 x = new byte [i];
20 static void BackgroundNoise ()
22 int i = 0;
23 while (true) {
24 AllocStuff ();
25 ++i;
29 static void AppDomainBackgroundNoise ()
31 for (int i = 0; i < 3; ++i) {
32 var t = new Thread (BackgroundNoise);
33 t.IsBackground = true;
34 t.Start ();
38 static void Main () {
39 for (int i = 0; i < 3; ++i) {
40 var t = new Thread (BackgroundNoise);
41 t.IsBackground = true;
42 t.Start ();
45 for (int i = 0; i < 100; ++i) {
46 var ad = AppDomain.CreateDomain ("domain_" + i);
47 ad.DoCallBack (new CrossAppDomainDelegate (AppDomainBackgroundNoise));
48 Thread.Sleep (10);
49 AppDomain.Unload (ad);
50 Console.Write (".");
51 if (i > 0 && i % 20 == 0) Console.WriteLine ();
53 Console.WriteLine ("\ndone");