2 // System.Threading.Thread.cs
5 // Dick Porter (dick@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
8 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Runtime.Remoting.Contexts;
31 using System.Runtime.Serialization;
32 using System.Runtime.Serialization.Formatters.Binary;
33 using System.Security.Permissions;
34 using System.Security.Principal;
35 using System.Globalization;
36 using System.Runtime.CompilerServices;
37 using System.Runtime.InteropServices;
39 using System.Collections;
40 using System.Security;
43 using System.Runtime.ConstrainedExecution;
46 namespace System.Threading {
48 [ClassInterface (ClassInterfaceType.None)]
51 [ComDefaultInterface (typeof (_Thread))]
53 public sealed class Thread : _Thread {
55 #region Sync with metadata/object-internals.h
57 // stores a thread handle
58 private IntPtr system_thread_handle;
60 /* Note this is an opaque object (an array), not a CultureInfo */
61 private object cached_culture_info;
62 private IntPtr unused0;
63 private bool threadpool_thread;
64 /* accessed only from unmanaged code */
67 private ThreadState state = ThreadState.Unstarted;
68 private object abort_exc;
69 internal object abort_state;
70 /* thread_id is only accessed from unmanaged code */
71 private Int64 thread_id;
73 /* start_notify is used by the runtime to signal that Start()
76 private IntPtr start_notify;
77 private IntPtr stack_ptr;
78 private IntPtr static_data;
79 private IntPtr jit_data;
80 private IntPtr lock_data;
81 Context current_appcontext;
84 private IntPtr appdomain_refs;
85 private bool interruption_requested;
86 private IntPtr suspend_event;
87 private IntPtr suspended_event;
88 private IntPtr resume_event;
89 /* Don't lock on synch_lock in managed code, since it can result in deadlocks */
90 private object synch_lock = new Object();
91 private IntPtr serialized_culture_info;
92 private int serialized_culture_info_len;
93 private IntPtr serialized_ui_culture_info;
94 private int serialized_ui_culture_info_len;
95 private ExecutionContext _ec;
97 * These fields are used to avoid having to increment corlib versions
98 * when a new field is added to the unmanaged MonoThread structure.
100 private IntPtr unused1;
101 private IntPtr unused2;
102 private IntPtr unused3;
103 private IntPtr unused4;
104 private IntPtr unused5;
105 private IntPtr unused6;
106 private IntPtr unused7;
109 // the name of local_slots is important as it's used by the runtime.
111 static object[] local_slots;
113 // can be both a ThreadSart and a ParameterizedThreadStart
114 private MulticastDelegate threadstart;
115 private string thread_name=null;
117 private IPrincipal _principal;
119 public static Context CurrentContext {
120 [SecurityPermission (SecurityAction.LinkDemand, Infrastructure=true)]
122 return(AppDomain.InternalGetContext ());
126 public static IPrincipal CurrentPrincipal {
129 Thread th = CurrentThread;
133 p = GetDomain ().DefaultPrincipal;
139 [SecurityPermission (SecurityAction.Demand, ControlPrincipal = true)]
141 CurrentThread._principal = value;
145 // Looks up the object associated with the current thread
146 [MethodImplAttribute(MethodImplOptions.InternalCall)]
147 private extern static Thread CurrentThread_internal();
149 public static Thread CurrentThread {
151 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
154 return(CurrentThread_internal());
158 internal static int CurrentThreadId {
160 return (int)(CurrentThread.thread_id);
164 // Stores a hash keyed by strings of LocalDataStoreSlot objects
165 static Hashtable datastorehash;
166 private static object datastore_lock = new object ();
168 private static void InitDataStoreHash () {
169 lock (datastore_lock) {
170 if (datastorehash == null) {
171 datastorehash = Hashtable.Synchronized(new Hashtable());
176 public static LocalDataStoreSlot AllocateNamedDataSlot (string name) {
177 lock (datastore_lock) {
178 if (datastorehash == null)
179 InitDataStoreHash ();
180 LocalDataStoreSlot slot = (LocalDataStoreSlot)datastorehash [name];
182 // This exception isnt documented (of
183 // course) but .net throws it
184 throw new ArgumentException("Named data slot already added");
187 slot = AllocateDataSlot ();
189 datastorehash.Add (name, slot);
195 public static void FreeNamedDataSlot (string name) {
196 lock (datastore_lock) {
197 if (datastorehash == null)
198 InitDataStoreHash ();
199 LocalDataStoreSlot slot = (LocalDataStoreSlot)datastorehash [name];
202 datastorehash.Remove (slot);
207 public static LocalDataStoreSlot AllocateDataSlot () {
208 return new LocalDataStoreSlot (true);
211 public static object GetData (LocalDataStoreSlot slot) {
212 object[] slots = local_slots;
214 throw new ArgumentNullException ("slot");
215 if (slots != null && slot.slot < slots.Length)
216 return slots [slot.slot];
220 public static void SetData (LocalDataStoreSlot slot, object data) {
221 object[] slots = local_slots;
223 throw new ArgumentNullException ("slot");
225 slots = new object [slot.slot + 2];
227 } else if (slot.slot >= slots.Length) {
228 object[] nslots = new object [slot.slot + 2];
229 slots.CopyTo (nslots, 0);
233 slots [slot.slot] = data;
236 public static AppDomain GetDomain() {
237 return AppDomain.CurrentDomain;
240 [MethodImplAttribute(MethodImplOptions.InternalCall)]
241 public extern static int GetDomainID();
243 [MethodImplAttribute (MethodImplOptions.InternalCall)]
244 internal extern static void FreeLocalSlotValues (int slot, bool thread_local);
246 public static LocalDataStoreSlot GetNamedDataSlot(string name) {
247 lock (datastore_lock) {
248 if (datastorehash == null)
249 InitDataStoreHash ();
250 LocalDataStoreSlot slot=(LocalDataStoreSlot)datastorehash[name];
253 slot=AllocateNamedDataSlot(name);
260 [MethodImplAttribute(MethodImplOptions.InternalCall)]
261 private extern static void ResetAbort_internal();
263 [SecurityPermission (SecurityAction.Demand, ControlThread=true)]
264 public static void ResetAbort ()
266 ResetAbort_internal ();
269 [MethodImplAttribute(MethodImplOptions.InternalCall)]
270 private extern static void Sleep_internal(int ms);
272 public static void Sleep(int millisecondsTimeout) {
273 if((millisecondsTimeout<0) && (millisecondsTimeout != Timeout.Infinite)) {
274 throw new ArgumentException("Negative timeout");
276 Sleep_internal(millisecondsTimeout);
279 public static void Sleep(TimeSpan timeout) {
280 // LAMESPEC: says to throw ArgumentException too
281 int ms=Convert.ToInt32(timeout.TotalMilliseconds);
283 if(ms < 0 || ms > Int32.MaxValue) {
284 throw new ArgumentOutOfRangeException("Timeout out of range");
290 // Returns the system thread handle
291 [MethodImplAttribute(MethodImplOptions.InternalCall)]
292 private extern IntPtr Thread_internal (MulticastDelegate start);
294 public Thread(ThreadStart start) {
296 throw new ArgumentNullException("Null ThreadStart");
303 [Obsolete ("Deprecated in favor of GetApartmentState, SetApartmentState and TrySetApartmentState.")]
305 public ApartmentState ApartmentState {
307 return(ApartmentState.Unknown);
314 [MethodImplAttribute (MethodImplOptions.InternalCall)]
315 private static extern int current_lcid ();
317 [MethodImplAttribute (MethodImplOptions.InternalCall)]
318 private extern CultureInfo GetCachedCurrentCulture ();
320 [MethodImplAttribute (MethodImplOptions.InternalCall)]
321 private extern byte[] GetSerializedCurrentCulture ();
323 [MethodImplAttribute (MethodImplOptions.InternalCall)]
324 private extern void SetCachedCurrentCulture (CultureInfo culture);
326 [MethodImplAttribute (MethodImplOptions.InternalCall)]
327 private extern void SetSerializedCurrentCulture (byte[] culture);
329 [MethodImplAttribute (MethodImplOptions.InternalCall)]
330 private extern CultureInfo GetCachedCurrentUICulture ();
332 [MethodImplAttribute (MethodImplOptions.InternalCall)]
333 private extern byte[] GetSerializedCurrentUICulture ();
335 [MethodImplAttribute (MethodImplOptions.InternalCall)]
336 private extern void SetCachedCurrentUICulture (CultureInfo culture);
338 [MethodImplAttribute (MethodImplOptions.InternalCall)]
339 private extern void SetSerializedCurrentUICulture (byte[] culture);
341 /* If the current_lcid() isn't known by CultureInfo,
342 * it will throw an exception which may cause
343 * String.Concat to try and recursively look up the
344 * CurrentCulture, which will throw an exception, etc.
345 * Use a boolean to short-circuit this scenario.
347 private static bool in_currentculture=false;
349 static object culture_lock = new object ();
352 * Thread objects are shared between appdomains, and CurrentCulture
353 * should always return an object in the calling appdomain. See bug
354 * http://bugzilla.ximian.com/show_bug.cgi?id=50049 for more info.
355 * This is hard to implement correctly and efficiently, so the current
356 * implementation is not perfect: changes made in one appdomain to the
357 * state of the current cultureinfo object are not visible to other
360 public CultureInfo CurrentCulture {
362 if (in_currentculture)
364 return CultureInfo.InvariantCulture;
366 CultureInfo culture = GetCachedCurrentCulture ();
370 byte[] arr = GetSerializedCurrentCulture ();
372 lock (culture_lock) {
373 in_currentculture=true;
374 culture = CultureInfo.ConstructCurrentCulture ();
376 // Don't serialize the culture in this case to avoid
377 // initializing the serialization infrastructure in the
378 // common case when the culture is not set explicitly.
380 SetCachedCurrentCulture (culture);
381 in_currentculture = false;
387 * No cultureinfo object exists for this domain, so create one
388 * by deserializing the serialized form.
390 in_currentculture = true;
392 BinaryFormatter bf = new BinaryFormatter ();
393 MemoryStream ms = new MemoryStream (arr);
394 culture = (CultureInfo)bf.Deserialize (ms);
395 SetCachedCurrentCulture (culture);
397 in_currentculture = false;
403 [SecurityPermission (SecurityAction.Demand, ControlThread=true)]
406 throw new ArgumentNullException ("value");
408 value.CheckNeutral ();
409 in_currentculture = true;
411 BinaryFormatter bf = new BinaryFormatter();
412 MemoryStream ms = new MemoryStream ();
413 bf.Serialize (ms, value);
415 SetCachedCurrentCulture (value);
416 SetSerializedCurrentCulture (ms.GetBuffer ());
418 in_currentculture = false;
423 public CultureInfo CurrentUICulture {
425 if (in_currentculture)
427 return CultureInfo.InvariantCulture;
429 CultureInfo culture = GetCachedCurrentUICulture ();
433 byte[] arr = GetSerializedCurrentUICulture ();
435 lock (culture_lock) {
436 in_currentculture=true;
443 culture = CultureInfo.ConstructCurrentUICulture ();
445 // Don't serialize the culture in this case to avoid
446 // initializing the serialization infrastructure in the
447 // common case when the culture is not set explicitly.
449 SetCachedCurrentUICulture (culture);
450 in_currentculture = false;
456 * No cultureinfo object exists for this domain, so create one
457 * by deserializing the serialized form.
459 in_currentculture = true;
461 BinaryFormatter bf = new BinaryFormatter ();
462 MemoryStream ms = new MemoryStream (arr);
463 culture = (CultureInfo)bf.Deserialize (ms);
464 SetCachedCurrentUICulture (culture);
467 in_currentculture = false;
474 in_currentculture = true;
477 throw new ArgumentNullException ("value");
480 BinaryFormatter bf = new BinaryFormatter();
481 MemoryStream ms = new MemoryStream ();
482 bf.Serialize (ms, value);
484 SetCachedCurrentUICulture (value);
485 SetSerializedCurrentUICulture (ms.GetBuffer ());
487 in_currentculture = false;
492 public bool IsThreadPoolThread {
494 return IsThreadPoolThreadInternal;
498 internal bool IsThreadPoolThreadInternal {
500 return threadpool_thread;
503 threadpool_thread = value;
507 public bool IsAlive {
509 ThreadState curstate = GetState ();
511 if((curstate & ThreadState.Aborted) != 0 ||
512 (curstate & ThreadState.Stopped) != 0 ||
513 (curstate & ThreadState.Unstarted) != 0) {
521 public bool IsBackground {
523 return (GetState () & ThreadState.Background) != 0;
528 SetState (ThreadState.Background);
530 ClrState (ThreadState.Background);
535 [MethodImplAttribute(MethodImplOptions.InternalCall)]
536 private extern string GetName_internal ();
538 [MethodImplAttribute(MethodImplOptions.InternalCall)]
539 private extern void SetName_internal (String name);
542 * The thread name must be shared by appdomains, so it is stored in
548 return GetName_internal ();
552 SetName_internal (value);
557 public ThreadPriority Priority {
559 return(ThreadPriority.Lowest);
566 public ThreadState ThreadState {
572 [MethodImplAttribute(MethodImplOptions.InternalCall)]
573 private extern void Abort_internal (object stateInfo);
575 [SecurityPermission (SecurityAction.Demand, ControlThread=true)]
578 Abort_internal (null);
581 [SecurityPermission (SecurityAction.Demand, ControlThread=true)]
582 public void Abort (object stateInfo)
584 Abort_internal (stateInfo);
589 [SecurityPermission (SecurityAction.Demand, ControlThread=true)]
590 public void Interrupt ()
592 throw new NotImplementedException ();
595 // The current thread joins with 'this'. Set ms to 0 to block
596 // until this actually exits.
597 [MethodImplAttribute(MethodImplOptions.InternalCall)]
598 private extern bool Join_internal(int ms, IntPtr handle);
602 Join_internal(Timeout.Infinite, system_thread_handle);
605 public bool Join(int millisecondsTimeout)
607 if (millisecondsTimeout != Timeout.Infinite && millisecondsTimeout < 0)
608 throw new ArgumentException ("Timeout less than zero", "millisecondsTimeout");
610 return Join_internal(millisecondsTimeout, system_thread_handle);
613 public bool Join(TimeSpan timeout)
615 // LAMESPEC: says to throw ArgumentException too
616 int ms=Convert.ToInt32(timeout.TotalMilliseconds);
618 if(ms < 0 || ms > Int32.MaxValue) {
619 throw new ArgumentOutOfRangeException("timeout out of range");
621 return Join_internal(ms, system_thread_handle);
625 [MethodImplAttribute(MethodImplOptions.InternalCall)]
626 public extern static void MemoryBarrier ();
628 [MethodImplAttribute(MethodImplOptions.InternalCall)]
629 private extern void Resume_internal();
634 [SecurityPermission (SecurityAction.Demand, ControlThread=true)]
635 public void Resume ()
642 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
644 public static void SpinWait (int iterations)
646 throw new NotImplementedException ();
649 public void Start() {
650 // propagate informations from the original thread to the new thread
652 if (!ExecutionContext.IsFlowSuppressed ())
653 _ec = ExecutionContext.Capture ();
655 // before 2.0 this was only used for security (mostly CAS) so we
656 // do this only if the security manager is active
657 if (SecurityManager.SecurityEnabled)
658 _ec = ExecutionContext.Capture ();
660 if (CurrentThread._principal != null)
661 _principal = CurrentThread._principal;
663 // Thread_internal creates and starts the new thread,
664 if (Thread_internal(threadstart) == (IntPtr) 0)
665 throw new SystemException ("Thread creation failed.");
668 [MethodImplAttribute(MethodImplOptions.InternalCall)]
669 private extern void Suspend_internal();
674 [SecurityPermission (SecurityAction.Demand, ControlThread=true)]
675 public void Suspend ()
680 // Closes the system thread handle
681 [MethodImplAttribute(MethodImplOptions.InternalCall)]
682 private extern void Thread_free_internal(IntPtr handle);
685 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
688 // Free up the handle
689 if (system_thread_handle != (IntPtr) 0)
690 Thread_free_internal(system_thread_handle);
693 [MethodImplAttribute (MethodImplOptions.InternalCall)]
694 extern private void SetState (ThreadState set);
696 [MethodImplAttribute (MethodImplOptions.InternalCall)]
697 extern private void ClrState (ThreadState clr);
699 [MethodImplAttribute (MethodImplOptions.InternalCall)]
700 extern private ThreadState GetState ();
704 [MethodImplAttribute (MethodImplOptions.InternalCall)]
705 extern public static byte VolatileRead (ref byte address);
707 [MethodImplAttribute (MethodImplOptions.InternalCall)]
708 extern public static double VolatileRead (ref double address);
710 [MethodImplAttribute (MethodImplOptions.InternalCall)]
711 extern public static short VolatileRead (ref short address);
713 [MethodImplAttribute (MethodImplOptions.InternalCall)]
714 extern public static int VolatileRead (ref int address);
716 [MethodImplAttribute (MethodImplOptions.InternalCall)]
717 extern public static long VolatileRead (ref long address);
719 [MethodImplAttribute (MethodImplOptions.InternalCall)]
720 extern public static IntPtr VolatileRead (ref IntPtr address);
722 [MethodImplAttribute (MethodImplOptions.InternalCall)]
723 extern public static object VolatileRead (ref object address);
725 [CLSCompliant(false)]
726 [MethodImplAttribute (MethodImplOptions.InternalCall)]
727 extern public static sbyte VolatileRead (ref sbyte address);
729 [MethodImplAttribute (MethodImplOptions.InternalCall)]
730 extern public static float VolatileRead (ref float address);
732 [CLSCompliant (false)]
733 [MethodImplAttribute (MethodImplOptions.InternalCall)]
734 extern public static ushort VolatileRead (ref ushort address);
736 [CLSCompliant (false)]
737 [MethodImplAttribute (MethodImplOptions.InternalCall)]
738 extern public static uint VolatileRead (ref uint address);
740 [CLSCompliant (false)]
741 [MethodImplAttribute (MethodImplOptions.InternalCall)]
742 extern public static ulong VolatileRead (ref ulong address);
744 [CLSCompliant (false)]
745 [MethodImplAttribute (MethodImplOptions.InternalCall)]
746 extern public static UIntPtr VolatileRead (ref UIntPtr address);
748 [MethodImplAttribute (MethodImplOptions.InternalCall)]
749 extern public static void VolatileWrite (ref byte address, byte value);
751 [MethodImplAttribute (MethodImplOptions.InternalCall)]
752 extern public static void VolatileWrite (ref double address, double value);
754 [MethodImplAttribute (MethodImplOptions.InternalCall)]
755 extern public static void VolatileWrite (ref short address, short value);
757 [MethodImplAttribute (MethodImplOptions.InternalCall)]
758 extern public static void VolatileWrite (ref int address, int value);
760 [MethodImplAttribute (MethodImplOptions.InternalCall)]
761 extern public static void VolatileWrite (ref long address, long value);
763 [MethodImplAttribute (MethodImplOptions.InternalCall)]
764 extern public static void VolatileWrite (ref IntPtr address, IntPtr value);
766 [MethodImplAttribute (MethodImplOptions.InternalCall)]
767 extern public static void VolatileWrite (ref object address, object value);
769 [CLSCompliant(false)]
770 [MethodImplAttribute (MethodImplOptions.InternalCall)]
771 extern public static void VolatileWrite (ref sbyte address, sbyte value);
773 [MethodImplAttribute (MethodImplOptions.InternalCall)]
774 extern public static void VolatileWrite (ref float address, float value);
776 [CLSCompliant (false)]
777 [MethodImplAttribute (MethodImplOptions.InternalCall)]
778 extern public static void VolatileWrite (ref ushort address, ushort value);
780 [CLSCompliant (false)]
781 [MethodImplAttribute (MethodImplOptions.InternalCall)]
782 extern public static void VolatileWrite (ref uint address, uint value);
784 [CLSCompliant (false)]
785 [MethodImplAttribute (MethodImplOptions.InternalCall)]
786 extern public static void VolatileWrite (ref ulong address, ulong value);
788 [CLSCompliant (false)]
789 [MethodImplAttribute (MethodImplOptions.InternalCall)]
790 extern public static void VolatileWrite (ref UIntPtr address, UIntPtr value);
795 public Thread (ThreadStart start, int maxStackSize)
798 throw new ArgumentNullException ("start");
799 if (maxStackSize < 131072)
800 throw new ArgumentException ("< 128 kb", "maxStackSize");
803 stack_size = maxStackSize;
806 public Thread (ParameterizedThreadStart start)
809 throw new ArgumentNullException ("start");
814 public Thread (ParameterizedThreadStart start, int maxStackSize)
817 throw new ArgumentNullException ("start");
818 if (maxStackSize < 131072)
819 throw new ArgumentException ("< 128 kb", "maxStackSize");
822 stack_size = maxStackSize;
825 [MonoTODO ("limited to CompressedStack support")]
826 public ExecutionContext ExecutionContext {
827 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
830 _ec = new ExecutionContext ();
835 public int ManagedThreadId {
836 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
837 get { return (int)thread_id; }
841 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
842 public static void BeginCriticalRegion ()
844 throw new NotImplementedException ();
848 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
849 public static void EndCriticalRegion ()
851 throw new NotImplementedException ();
855 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.MayFail)]
856 public static void BeginThreadAffinity ()
858 throw new NotImplementedException ();
862 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.MayFail)]
863 public static void EndThreadAffinity ()
865 throw new NotImplementedException ();
869 // We disable warning 618, because we are accessing the
870 // empty property ApartmentState which produces an Obsolete
871 // message, but since its an empty routine needed for 1.x
874 // Maybe we should later turn these into internal methods for 1.x
875 // instead and have the property call these.
879 public ApartmentState GetApartmentState ()
881 return this.ApartmentState;
885 public void SetApartmentState (ApartmentState state)
887 this.ApartmentState = state;
891 public bool TrySetApartmentState (ApartmentState state)
894 this.ApartmentState = state;
897 catch (ArgumentException) {
906 public override int GetHashCode ()
908 // ??? overridden but not guaranteed to be unique ???
909 return (int)thread_id;
912 public void Start (object parameter)
914 start_obj = parameter;
918 internal ExecutionContext ExecutionContext {
921 _ec = new ExecutionContext ();
927 // NOTE: This method doesn't show in the class library status page because
928 // it cannot be "found" with the StrongNameIdentityPermission for ECMA key.
930 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
931 [StrongNameIdentityPermission (SecurityAction.LinkDemand, PublicKey="00000000000000000400000000000000")]
933 [Obsolete ("see CompressedStack class")]
940 CompressedStack GetCompressedStack ()
942 // Note: returns null if no CompressedStack has been set.
943 // However CompressedStack.GetCompressedStack returns an
944 // (empty?) CompressedStack instance.
945 CompressedStack cs = ExecutionContext.SecurityContext.CompressedStack;
946 return ((cs == null) || cs.IsEmpty ()) ? null : cs.CreateCopy ();
949 // NOTE: This method doesn't show in the class library status page because
950 // it cannot be "found" with the StrongNameIdentityPermission for ECMA key.
952 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
953 [StrongNameIdentityPermission (SecurityAction.LinkDemand, PublicKey="00000000000000000400000000000000")]
955 [Obsolete ("see CompressedStack class")]
962 void SetCompressedStack (CompressedStack stack)
964 ExecutionContext.SecurityContext.CompressedStack = stack;
968 void _Thread.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
970 throw new NotImplementedException ();
973 void _Thread.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
975 throw new NotImplementedException ();
978 void _Thread.GetTypeInfoCount (out uint pcTInfo)
980 throw new NotImplementedException ();
983 void _Thread.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams,
984 IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
986 throw new NotImplementedException ();