2 using System
.Collections
;
3 using System
.Collections
.Generic
;
4 using System
.Threading
;
9 public List
<object> link
= new List
<object> ();
16 static WeakReference
<Bridge
> root
, child
;
18 static void SetupLinks () {
19 var a
= new Bridge () { id = "bridge" }
;
20 var b
= new Bridge () { id = "child" }
;
24 root
= new WeakReference
<Bridge
> (a
, true);
25 child
= new WeakReference
<Bridge
> (b
, true);
30 var t
= new Thread (SetupLinks
);
37 Console
.WriteLine ("try get A {0}", root
.TryGetTarget (out a
));
38 Console
.WriteLine ("try get B {0}", child
.TryGetTarget (out b
));
39 Console
.WriteLine ("a is null {0}", a
== null);
40 Console
.WriteLine ("b is null {0}", b
== null);
41 if (a
== null || b
== null)
44 Console
.WriteLine ("a test {0}", a
.__test
);
45 Console
.WriteLine ("b test {0}", b
.__test
);
47 if (a
.__test
!= 1 || b
.__test
!= 3)