2007-03-28 Chris Toshok <toshok@ximian.com>
[mono-project.git] / mono / tests / finalizer-exception.cs
blobef0b4f6e13ab59afe350cfa48c38c77763bd92c2
2 using System;
3 using System.Collections;
4 using System.Threading;
6 public class foo {
7 public static LocalDataStoreSlot dataslot = Thread.AllocateDataSlot();
8 public static int final_count=0;
10 ~foo() {
11 // Demonstrate that this is still the same thread
12 string ID=(string)Thread.GetData(dataslot);
13 if(ID==null) {
14 Console.WriteLine("Set ID: foo");
15 Thread.SetData(dataslot, "foo");
18 // Don't run forever
19 if(final_count++>10) {
20 Environment.Exit(0);
23 Console.WriteLine("finalizer thread ID: {0}", (string)Thread.GetData(dataslot));
24 throw new SystemException("wibble");
27 public static int Main() {
28 ArrayList list = new ArrayList ();
29 Thread.SetData(dataslot, "ID is wibble");
30 Environment.ExitCode = 2;
31 while(true) {
32 foo instance = new foo();
33 list.Add (new WeakReference(instance));
35 return 1;