[corlib] Small part of thread from reference sources
[mono.git] / mcs / class / corlib / System.Threading / CompressedStack.cs
index e440ba068b70b52d7a9cc3dcca3d9ea42cf4c733..b8a1535e0d7c75565baee70a6c7f3daa7e81dff3 100644 (file)
@@ -65,7 +65,7 @@ namespace System.Threading {
                        cs._list = SecurityFrame.GetStack (1);
 
                        // include any current CompressedStack inside the new Capture
-                       CompressedStack currentCs = Thread.CurrentThread.GetCompressedStack ();
+                       CompressedStack currentCs = Thread.CurrentThread.ExecutionContext.SecurityContext.CompressedStack;
                        if (currentCs != null) {
                                for (int i=0; i < currentCs._list.Count; i++)
                                        cs._list.Add (currentCs._list [i]);
@@ -82,10 +82,12 @@ namespace System.Threading {
                        // Note: CompressedStack.GetCompressedStack doesn't return null
                        // like Thread.CurrentThread.GetCompressedStack if no compressed
                        // stack is present.
-                       CompressedStack cs = Thread.CurrentThread.GetCompressedStack ();
-                       if (cs == null) {
+
+            CompressedStack cs = Thread.CurrentThread.ExecutionContext.SecurityContext.CompressedStack;
+                       if (cs == null || cs.IsEmpty ()) {
                                cs = CompressedStack.Capture ();
                        } else {
+                               cs = cs.CreateCopy ();
                                // merge the existing compressed stack (from a previous Thread) with the current
                                // Thread stack so we can assign "all of it" to yet another Thread
                                CompressedStack newstack = CompressedStack.Capture ();
@@ -112,13 +114,13 @@ namespace System.Threading {
                        Thread t = Thread.CurrentThread;
                        CompressedStack original = null;
                        try {
-                               original = t.GetCompressedStack ()
-                               t.SetCompressedStack (compressedStack);
+                               original = t.ExecutionContext.SecurityContext.CompressedStack
+                               t.ExecutionContext.SecurityContext.CompressedStack = compressedStack;
                                callback (state);
                        }
                        finally {
                                if (original != null)
-                                       t.SetCompressedStack (original);
+                                       t.ExecutionContext.SecurityContext.CompressedStack = original;
                        }
                }