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]);
// 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 ();
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;
}
}
}
}
- [ClassInterface (ClassInterfaceType.None)]
- [ComVisible (true)]
- [ComDefaultInterface (typeof (_Thread))]
[StructLayout (LayoutKind.Sequential)]
-#if MOBILE
- public sealed class Thread : CriticalFinalizerObject {
-#else
- public sealed class Thread : CriticalFinalizerObject, _Thread {
-#endif
+ public sealed partial class Thread {
#pragma warning disable 414
#region Sync with metadata/object-internals.h
private InternalThread internal_thread;
- object start_obj;
+ object m_ThreadStartArg;
private ExecutionContext ec_to_set;
#endregion
#pragma warning restore 414
static internal CultureInfo default_ui_culture;
// can be both a ThreadStart and a ParameterizedThreadStart
- private MulticastDelegate threadstart;
+ private MulticastDelegate m_Delegate;
//private string thread_name=null;
[MethodImplAttribute(MethodImplOptions.InternalCall)]
if(start==null) {
throw new ArgumentNullException("Null ThreadStart");
}
- threadstart=start;
+ m_Delegate=start;
}
private Thread (InternalThread it) {
{
current_thread = this;
- if (threadstart is ThreadStart) {
- ((ThreadStart) threadstart) ();
+ if (m_Delegate is ThreadStart) {
+ ((ThreadStart) m_Delegate) ();
} else {
- ((ParameterizedThreadStart) threadstart) (start_obj);
+ ((ParameterizedThreadStart) m_Delegate) (m_ThreadStartArg);
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
extern static int SystemMaxStackStize ();
- static int CheckStackSize (int maxStackSize)
+ static int GetProcessDefaultStackSize (int maxStackSize)
{
- if (maxStackSize < 0)
- throw new ArgumentOutOfRangeException ("less than zero", "maxStackSize");
-
if (maxStackSize < 131072) // make sure stack is at least 128k big
return 131072;
return Math.Min (maxStackSize, SystemMaxStackStize ());
}
- public Thread (ThreadStart start, int maxStackSize)
- {
- if (start == null)
- throw new ArgumentNullException ("start");
-
- threadstart = start;
- Internal.stack_size = CheckStackSize (maxStackSize);;
- }
-
- public Thread (ParameterizedThreadStart start)
+ void SetStart (MulticastDelegate start, int maxStackSize)
{
- if (start == null)
- throw new ArgumentNullException ("start");
-
- threadstart = start;
- }
-
- public Thread (ParameterizedThreadStart start, int maxStackSize)
- {
- if (start == null)
- throw new ArgumentNullException ("start");
-
- threadstart = start;
- Internal.stack_size = CheckStackSize (maxStackSize);
+ m_Delegate = start;
+ Internal.stack_size = maxStackSize;
}
public ExecutionContext ExecutionContext {
public void Start (object parameter)
{
- start_obj = parameter;
+ m_ThreadStartArg = parameter;
Start ();
}
- // NOTE: This method doesn't show in the class library status page because
- // it cannot be "found" with the StrongNameIdentityPermission for ECMA key.
- // But it's there!
- [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
- [StrongNameIdentityPermission (SecurityAction.LinkDemand, PublicKey="00000000000000000400000000000000")]
- [Obsolete ("see CompressedStack class")]
- public CompressedStack GetCompressedStack ()
- {
-#if MOBILE
- throw new NotSupportedException ();
-#else
- // Note: returns null if no CompressedStack has been set.
- // However CompressedStack.GetCompressedStack returns an
- // (empty?) CompressedStack instance.
- CompressedStack cs = ExecutionContext.SecurityContext.CompressedStack;
- return ((cs == null) || cs.IsEmpty ()) ? null : cs.CreateCopy ();
-#endif
- }
-
- // NOTE: This method doesn't show in the class library status page because
- // it cannot be "found" with the StrongNameIdentityPermission for ECMA key.
- // But it's there!
- [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
- [StrongNameIdentityPermission (SecurityAction.LinkDemand, PublicKey="00000000000000000400000000000000")]
- [Obsolete ("see CompressedStack class")]
- public void SetCompressedStack (CompressedStack stack)
- {
-#if MOBILE
- throw new NotSupportedException ();
-#else
- ExecutionContext.SecurityContext.CompressedStack = stack;
-#endif
- }
-
#if !MOBILE
void _Thread.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{