3 using System
.Collections
;
4 using System
.Threading
;
7 public static LocalDataStoreSlot dataslot
= Thread
.AllocateDataSlot();
8 public static int final_count
=0;
11 // Demonstrate that this is still the same thread
12 string ID
=(string)Thread
.GetData(dataslot
);
14 Console
.WriteLine("Set ID: foo");
15 Thread
.SetData(dataslot
, "foo");
19 if(final_count
++>10) {
23 Console
.WriteLine("finalizer thread ID: {0}", (string)Thread
.GetData(dataslot
));
25 Thread
.CurrentThread
.Abort();
26 } catch(ThreadAbortException
) {
27 Console
.WriteLine("Aborted!");
32 public static int Main() {
33 ArrayList list
= new ArrayList ();
34 Thread
.SetData(dataslot
, "ID is wibble");
35 Environment
.ExitCode
= 2;
37 foo instance
= new foo();
38 list
.Add (new WeakReference(instance
));