We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
-
Expand
Microsoft.Win32
-
Expand
Microsoft.Win32.SafeHandles
-
Expand
System
-
Expand
System.Runtime.Hosting
-
Expand
System.Runtime.InteropServices
-
Expand
System.Runtime.CompilerServices
-
Expand
System.Collections
-
Expand
System.Collections.Generic
-
Expand
System.Collections.ObjectModel
-
Expand
System.Configuration.Assemblies
-
Expand
System.Diagnostics
-
Expand
System.Diagnostics.CodeAnalysis
-
Expand
System.Diagnostics.SymbolStore
-
Expand
System.Globalization
-
Expand
System.IO
-
Expand
System.IO.IsolatedStorage
-
Expand
System.Reflection
-
Expand
System.Reflection.Cache
-
Expand
System.Reflection.Emit
-
Expand
System.Resources
-
Expand
System.Runtime
-
Expand
System.Runtime.InteropServices.Expando
-
Expand
System.Runtime.ConstrainedExecution
-
Expand
System.Runtime.Remoting.Activation
-
Expand
System.Runtime.Remoting.Messaging
-
Expand
System.Runtime.Remoting.Channels
-
Expand
System.Runtime.Remoting.Lifetime
-
Expand
System.Runtime.Remoting
-
Expand
System.Runtime.Remoting.Contexts
-
Expand
System.Runtime.Remoting.Proxies
-
Expand
System.Runtime.Remoting.Metadata
-
Expand
System.Runtime.Remoting.Metadata.W3cXsd2001
-
Expand
System.Runtime.Remoting.Services
-
Expand
System.Runtime.Serialization
-
Expand
System.Runtime.Serialization.Formatters
-
Expand
System.Runtime.Serialization.Formatters.Binary
-
Expand
System.Runtime.Versioning
-
Expand
System.Security
-
Expand
System.Security.Cryptography
-
Expand
System.Security.Cryptography.X509Certificates
-
Expand
System.Security.Permissions
-
Expand
System.Security.Policy
-
Expand
System.Security.Principal
-
Expand
System.Security.Util
-
Expand
System.Text
-
Expand
System.Threading
-
Expand
_IOCompletionCallback
-
Expand
_ThreadPoolWaitCallback
-
Expand
_ThreadPoolWaitOrTimerCallback
-
Expand
_TimerCallback
-
Expand
AbandonedMutexException
-
Expand
AsyncFlowControl
-
Expand
AutoResetEvent
-
Expand
CancellationRegion
-
Expand
CancellationSignal
-
Expand
CompressedStack
-
Expand
CompressedStackRunData
-
Expand
CompressedStackSwitcher
-
Expand
DomainCompressedStack
-
Expand
EventResetMode
-
Expand
EventWaitHandle
-
Expand
ExceptionType
-
Expand
ExecutionContext
-
Expand
ExecutionContextRunData
-
Expand
ExecutionContextSwitcher
-
Expand
HostExecutionContext
-
Expand
HostExecutionContextManager
-
Expand
HostExecutionContextSwitcher
-
Expand
Interlocked
-
Expand
IUnknownSafeHandle
-
Expand
LockCookie
-
Expand
ManualResetEvent
-
Expand
Monitor
-
Expand
Mutex
-
Expand
MutexCleanupInfo
-
Expand
NativeOverlapped
-
Expand
Overlapped
-
Expand
OverlappedData
-
Expand
OverlappedDataCache
-
Expand
OverlappedDataCacheLine
-
Expand
ReaderWriterLock
-
Expand
RegisteredWaitHandle
-
Expand
RegisteredWaitHandleSafe
-
Expand
SafeCompressedStackHandle
-
Expand
Semaphore
-
Expand
SemaphoreFullException
-
Expand
StackCrawlMark
-
Expand
SynchronizationContext
-
Expand
SynchronizationContextProperties
-
Expand
SynchronizationContextSwitcher
-
Expand
SynchronizationLockException
-
Expand
Thread
-
Abort()
-
Abort(object)
-
AbortInternal()
-
AbortReason()
-
AllocateDataSlot()
-
AllocateNamedDataSlot(string)
-
BeginCriticalRegion()
-
BeginThreadAffinity()
-
ClearAbortReason()
-
CompleteCrossContextCallback(InternalCrossContextDelegate, object)
-
CurrentContext()
-
CurrentCulture()
-
CurrentPrincipal()
-
CurrentThread()
-
CurrentUICulture()
-
EndCriticalRegion()
-
EndThreadAffinity()
-
ExecutionContext()
-
FindSlot()
-
FreeNamedDataSlot(string)
-
GetAbortReason()
-
GetCompressedStack()
-
GetContextInternal(IntPtr)
-
GetCurrentContextInternal()
-
GetCurrentThreadNative()
-
GetData(LocalDataStoreSlot)
-
GetDomain()
-
GetDomainID()
-
GetDomainInternal()
-
GetDomainLocalStore()
-
GetExecutionContextNoCreate()
-
GetFastCurrentThreadNative()
-
GetFastDomainInternal()
-
GetHashCode()
-
GetIDsOfNames(Guid, IntPtr, uint, uint, IntPtr)
-
GetIllogicalCallContext()
-
GetLogicalCallContext()
-
GetNamedDataSlot(string)
-
GetPriorityNative()
-
GetThreadStateNative()
-
GetTypeInfo(uint, uint, IntPtr)
-
GetTypeInfoCount(uint)
-
InformThreadNameChangeEx(Thread, string)
-
InternalCrossContextCallback(Context, InternalCrossContextDelegate, object)
-
InternalCrossContextCallback(Context, IntPtr, Int32, InternalCrossContextDelegate, object)
-
InternalFinalize()
-
InternalGetCurrentThread()
-
Interrupt()
-
InterruptInternal()
-
Invoke(uint, Guid, uint, short, IntPtr, IntPtr, IntPtr, IntPtr)
-
IsAlive()
-
IsAliveNative()
-
IsBackground()
-
IsBackgroundNative()
-
IsThreadPoolThread()
-
IsThreadpoolThreadNative()
-
Join()
-
Join(int)
-
Join(TimeSpan)
-
JoinInternal()
-
JoinInternal(int)
-
LocalDataStoreManager()
-
ManagedThreadId()
-
MemoryBarrier()
-
Name()
-
nativeGetSafeCulture(Thread, int, bool, CultureInfo)
-
nativeSetThreadUILocale(int)
-
Priority()
-
RemoveDomainLocalStore(LocalDataStore)
-
ReserveSlot()
-
ResetAbort()
-
ResetAbortNative()
-
RestoreAppDomainStack(IntPtr)
-
Resume()
-
ResumeInternal()
-
SetAbortReason(object)
-
SetAppDomainStack(SafeCompressedStackHandle)
-
SetBackgroundNative(bool)
-
SetCompressedStack(CompressedStack)
-
SetData(LocalDataStoreSlot, object)
-
SetDomainLocalStore(LocalDataStore)
-
SetExecutionContext(ExecutionContext)
-
SetIsThreadStaticsArray(object)
-
SetLogicalCallContext(LogicalCallContext)
-
SetPrincipalInternal(IPrincipal)
-
SetPriorityNative(int)
-
SetStart(Delegate, int)
-
SetStartHelper(Delegate, int)
-
Sleep(int)
-
Sleep(TimeSpan)
-
SleepInternal(int)
-
SpinWait(int)
-
SpinWaitInternal(int)
-
Start()
-
Start(object)
-
StartInternal(IPrincipal, StackCrawlMark)
-
Suspend()
-
SuspendInternal()
-
Thread(ParameterizedThreadStart)
-
Thread(ParameterizedThreadStart, int)
-
Thread(ThreadStart)
-
Thread(ThreadStart, int)
-
ThreadState()
-
VolatileRead(byte)
-
VolatileRead(double)
-
VolatileRead(float)
-
VolatileRead(int)
-
VolatileRead(IntPtr)
-
VolatileRead(long)
-
VolatileRead(object)
-
VolatileRead(sbyte)
-
VolatileRead(short)
-
VolatileRead(uint)
-
VolatileRead(UIntPtr)
-
VolatileRead(ulong)
-
VolatileRead(ushort)
-
VolatileWrite(byte, byte)
-
VolatileWrite(double, double)
-
VolatileWrite(float, float)
-
VolatileWrite(int, int)
-
VolatileWrite(IntPtr, IntPtr)
-
VolatileWrite(long, long)
-
VolatileWrite(object, object)
-
VolatileWrite(sbyte, sbyte)
-
VolatileWrite(short, short)
-
VolatileWrite(uint, uint)
-
VolatileWrite(UIntPtr, UIntPtr)
-
VolatileWrite(ulong, ulong)
-
VolatileWrite(ushort, ushort)
-
Expand
ThreadAbortException
-
Expand
ThreadHelper
-
Expand
ThreadInterruptedException
-
Expand
ThreadPool
-
Expand
ThreadPriority
-
Expand
ThreadStartException
-
Expand
ThreadState
-
Expand
ThreadStateException
-
Expand
Timeout
-
Expand
Timer
-
Expand
TimerBase
-
Expand
WaitHandle
-
Expand
WaitHandleCannotBeOpenedException
-
Expand
System.Runtime.Remoting.Channels.Http
-
Expand
System.Runtime.Remoting.Channels.Tcp
-
Expand
System.Runtime.Remoting.MetadataServices
-
Expand
System.Runtime.Serialization.Formatters.Soap.Xml
-
Expand
System.Runtime.Serialization.Formatters.Soap
-
Expand
Microsoft.Tools.Caspol
-
Expand
Microsoft.Tools.Build
-
Expand
Microsoft.CSharp
-
Expand
System.CodeDom
-
Expand
System.CodeDom.Compiler
-
Expand
System.Collections.Specialized
-
Expand
System.ComponentModel
-
Expand
System.ComponentModel.Design
-
Expand
System.ComponentModel.Design.Serialization
-
Expand
System.Configuration
-
Expand
System.Web
-
Expand
System.Configuration.Provider
-
Expand
System.Configuration.Internal
-
Expand
System.Internal
-
Expand
System.Windows.Forms
-
Expand
System.Net
-
Expand
System.Net.Sockets
-
Expand
System.Net.NetworkInformation
-
Expand
System.Net.ComImports
-
Expand
System.Net.Security
-
Expand
System.Net.Cache
-
Expand
System.Net.Configuration
-
Expand
System.Text.RegularExpressions
-
Expand
System.Tools
-
Expand
System.IO.Compression
-
Expand
System.IO.Ports
-
Expand
System.Security.AccessControl
-
Expand
System.Xml
-
Expand
System.Xml.XPath.DataBinding
-
Expand
System.Xml.Schema
-
Expand
System.Xml.Serialization
-
Expand
System.Xml.Serialization.Advanced
-
Expand
System.Xml.Serialization.Configuration
-
Expand
System.Xml.XPath
-
Expand
System.Xml.Xsl
-
Expand
System.Xml.Xsl.IlGen
-
Expand
System.Xml.Xsl.Qil
-
Expand
System.Xml.Xsl.Runtime
-
Expand
System.Xml.Xsl.XPath
-
Expand
System.Xml.Xsl.Xslt
-
Expand
System.Xml.Xsl.XsltOld
-
Expand
System.Xml.Xsl.XsltOld.Debugger
-
Expand
Microsoft.JScript
-
Expand
Microsoft.Vsa
-
Expand
Microsoft.JScript.Vsa
- namespace System.Threading
- {
- using System.Threading;
- using System.Runtime.InteropServices;
- using System.Runtime.Remoting.Contexts;
- using System.Runtime.Remoting.Messaging;
- using System;
- using System.Diagnostics;
- using System.Security.Permissions;
- using System.Security.Principal;
- using System.Globalization;
- using System.Collections.Generic;
- using System.Runtime.Serialization;
- using System.Runtime.CompilerServices;
- using System.Runtime.ConstrainedExecution;
- using System.Security;
- using System.Runtime.Versioning;
-
- internal delegate object InternalCrossContextDelegate(object[] args);
-
- internal class ThreadHelper
- {
- Delegate _start;
- object _startArg = null;
- ExecutionContext _executionContext = null;
- internal ThreadHelper(Delegate start)
- {
- _start = start;
- }
-
- internal void SetExecutionContextHelper(ExecutionContext ec)
- {
- _executionContext = ec;
- }
- static internal ContextCallback _ccb = new ContextCallback(ThreadStart_Context);
- static internal void ThreadStart_Context(object state)
- {
- ThreadHelper t = (ThreadHelper)state;
- if (t._start is ThreadStart) {
- ((ThreadStart)t._start)();
- }
- else {
- ((ParameterizedThreadStart)t._start)(t._startArg);
- }
- }
-
-
- internal void ThreadStart(object obj)
- {
- _startArg = obj;
- if (_executionContext != null) {
- ExecutionContext.Run(_executionContext, _ccb, (object)this);
- }
- else {
- ((ParameterizedThreadStart)_start)(obj);
- }
- }
-
-
- internal void ThreadStart()
- {
- if (_executionContext != null) {
- ExecutionContext.Run(_executionContext, _ccb, (object)this);
- }
- else {
- ((ThreadStart)_start)();
- }
- }
- }
-
-
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_Thread))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class Thread : CriticalFinalizerObject, _Thread
- {
-
- private Context m_Context;
-
- private ExecutionContext m_ExecutionContext;
-
- private string m_Name;
- private Delegate m_Delegate;
-
- private object[][] m_ThreadStaticsBuckets;
-
- private int[] m_ThreadStaticsBits;
-
- private CultureInfo m_CurrentCulture;
- private CultureInfo m_CurrentUICulture;
- private object m_ThreadStartArg;
-
-
- #pragma warning disable 169
- #pragma warning disable 414 // These fields are not used from managed.
-
-
-
- private IntPtr DONT_USE_InternalThread;
-
- private int m_Priority;
-
- #pragma warning restore 414
- #pragma warning restore 169
-
- private static LocalDataStoreMgr s_LocalDataStoreMgr = null;
- private static object s_SyncObject = new object();
-
-
- private const int STATICS_BUCKET_SIZE = 32;
-
-
- public Thread(ThreadStart start)
- {
- if (start == null) {
- throw new ArgumentNullException("start");
- }
- SetStartHelper((Delegate)start, 0);
-
- }
-
- public Thread(ThreadStart start, int maxStackSize)
- {
- if (start == null) {
- throw new ArgumentNullException("start");
- }
- if (0 > maxStackSize)
- throw new ArgumentOutOfRangeException("maxStackSize", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- SetStartHelper((Delegate)start, maxStackSize);
- }
- public Thread(ParameterizedThreadStart start)
- {
- if (start == null) {
- throw new ArgumentNullException("start");
- }
- SetStartHelper((Delegate)start, 0);
- }
-
- public Thread(ParameterizedThreadStart start, int maxStackSize)
- {
- if (start == null) {
- throw new ArgumentNullException("start");
- }
- if (0 > maxStackSize)
- throw new ArgumentOutOfRangeException("maxStackSize", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- SetStartHelper((Delegate)start, maxStackSize);
- }
-
- [ComVisible(false), MethodImplAttribute(MethodImplOptions.InternalCall)]
- public override extern int GetHashCode();
-
- public extern int ManagedThreadId {
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- get;
- }
-
-
- [HostProtection(Synchronization = true, ExternalThreading = true)]
- public void Start()
- {
-
-
-
-
- if (m_Delegate != null) {
- ThreadHelper t = (ThreadHelper)(m_Delegate.Target);
- ExecutionContext ec = ExecutionContext.Capture();
- ExecutionContext.ClearSyncContext(ec);
- t.SetExecutionContextHelper(ec);
- }
- IPrincipal principal = (IPrincipal)CallContext.Principal;
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- StartInternal(principal, ref stackMark);
- }
-
- [HostProtection(Synchronization = true, ExternalThreading = true)]
- public void Start(object parameter)
- {
-
-
- if (m_Delegate is ThreadStart) {
-
-
-
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ThreadWrongThreadStart"));
- }
- m_ThreadStartArg = parameter;
- Start();
- }
-
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- internal ExecutionContext GetExecutionContextNoCreate()
- {
- return m_ExecutionContext;
- }
-
-
-
- public ExecutionContext ExecutionContext {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- get {
- if (m_ExecutionContext == null && this == Thread.CurrentThread) {
- m_ExecutionContext = new ExecutionContext();
- m_ExecutionContext.Thread = this;
- }
- return m_ExecutionContext;
- }
- }
-
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- internal void SetExecutionContext(ExecutionContext value)
- {
- m_ExecutionContext = value;
- if (value != null)
- m_ExecutionContext.Thread = this;
- }
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void StartInternal(IPrincipal principal, ref StackCrawlMark stackMark);
-
- /// <internalonly/>
- [StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0x00000000000000000400000000000000"), SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode), DynamicSecurityMethodAttribute()]
- [Obsolete("Thread.SetCompressedStack is no longer supported. Please use the System.Threading.CompressedStack class")]
- public void SetCompressedStack(CompressedStack stack)
- {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ThreadAPIsNotSupported"));
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- internal extern IntPtr SetAppDomainStack(SafeCompressedStackHandle csHandle);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- internal extern void RestoreAppDomainStack(IntPtr appDomainStack);
-
-
- /// <internalonly/>
- [StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0x00000000000000000400000000000000"), SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
- [Obsolete("Thread.GetCompressedStack is no longer supported. Please use the System.Threading.CompressedStack class")]
- public CompressedStack GetCompressedStack()
- {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ThreadAPIsNotSupported"));
- }
-
-
-
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern IntPtr InternalGetCurrentThread();
-
-
-
- [SecurityPermissionAttribute(SecurityAction.Demand, ControlThread = true)]
- public void Abort(object stateInfo)
- {
-
-
-
-
-
-
- AbortReason = stateInfo;
-
-
-
-
-
-
- AbortInternal();
- }
-
- [SecurityPermissionAttribute(SecurityAction.Demand, ControlThread = true)]
- public void Abort()
- {
- AbortInternal();
- }
-
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void AbortInternal();
-
-
- [SecurityPermissionAttribute(SecurityAction.Demand, ControlThread = true)]
- public static void ResetAbort()
- {
- Thread thread = Thread.CurrentThread;
- if ((thread.ThreadState & ThreadState.AbortRequested) == 0)
- throw new ThreadStateException(Environment.GetResourceString("ThreadState_NoAbortRequested"));
- thread.ResetAbortNative();
- thread.ClearAbortReason();
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void ResetAbortNative();
-
-
- [Obsolete("Thread.Suspend has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [SecurityPermission(SecurityAction.Demand, ControlThread = true)]
- [SecurityPermission(SecurityAction.Demand, ControlThread = true)]
- public void Suspend()
- {
- SuspendInternal();
- }
-
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void SuspendInternal();
-
-
- [Obsolete("Thread.Resume has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [SecurityPermission(SecurityAction.Demand, ControlThread = true)]
- public void Resume()
- {
- ResumeInternal();
- }
-
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void ResumeInternal();
-
-
- [SecurityPermission(SecurityAction.Demand, ControlThread = true)]
- public void Interrupt()
- {
- InterruptInternal();
- }
-
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void InterruptInternal();
-
-
- public ThreadPriority Priority {
- get { return (ThreadPriority)GetPriorityNative(); }
- [HostProtection(SelfAffectingThreading = true)]
- set { SetPriorityNative((int)value); }
- }
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern int GetPriorityNative();
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void SetPriorityNative(int priority);
-
-
- public bool IsAlive {
- get { return IsAliveNative(); }
- }
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern bool IsAliveNative();
-
-
- public bool IsThreadPoolThread {
- get { return IsThreadpoolThreadNative(); }
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern bool IsThreadpoolThreadNative();
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- [HostProtection(Synchronization = true, ExternalThreading = true)]
- private extern void JoinInternal();
-
- [HostProtection(Synchronization = true, ExternalThreading = true)]
- public void Join()
- {
- JoinInternal();
- }
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- [HostProtection(Synchronization = true, ExternalThreading = true)]
- private extern bool JoinInternal(int millisecondsTimeout);
-
- [HostProtection(Synchronization = true, ExternalThreading = true)]
- public bool Join(int millisecondsTimeout)
- {
- return JoinInternal(millisecondsTimeout);
- }
-
- [HostProtection(Synchronization = true, ExternalThreading = true)]
- public bool Join(TimeSpan timeout)
- {
- long tm = (long)timeout.TotalMilliseconds;
- if (tm < -1 || tm > (long)Int32.MaxValue)
- throw new ArgumentOutOfRangeException("timeout", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1"));
-
- return Join((int)tm);
- }
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void SleepInternal(int millisecondsTimeout);
-
- public static void Sleep(int millisecondsTimeout)
- {
- SleepInternal(millisecondsTimeout);
- }
-
- public static void Sleep(TimeSpan timeout)
- {
- long tm = (long)timeout.TotalMilliseconds;
- if (tm < -1 || tm > (long)Int32.MaxValue)
- throw new ArgumentOutOfRangeException("timeout", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1"));
- Sleep((int)tm);
- }
-
-
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall), HostProtection(Synchronization = true, ExternalThreading = true), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- private static extern void SpinWaitInternal(int iterations);
-
- [HostProtection(Synchronization = true, ExternalThreading = true), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- public static void SpinWait(int iterations)
- {
- SpinWaitInternal(iterations);
- }
-
-
- public static Thread CurrentThread {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- get {
- Thread th;
- th = GetFastCurrentThreadNative();
- if (th == null)
- th = GetCurrentThreadNative();
- return th;
- }
- }
- [MethodImplAttribute(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- private static extern Thread GetCurrentThreadNative();
- [MethodImplAttribute(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- private static extern Thread GetFastCurrentThreadNative();
-
- private void SetStartHelper(Delegate start, int maxStackSize)
- {
- ThreadHelper threadStartCallBack = new ThreadHelper(start);
- if (start is ThreadStart) {
- SetStart(new ThreadStart(threadStartCallBack.ThreadStart), maxStackSize);
- }
- else {
- SetStart(new ParameterizedThreadStart(threadStartCallBack.ThreadStart), maxStackSize);
- }
- }
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void SetStart(Delegate start, int maxStackSize);
-
-
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- ~Thread()
- {
-
- InternalFinalize();
- }
-
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void InternalFinalize();
-
-
-
- public bool IsBackground {
- get { return IsBackgroundNative(); }
- [HostProtection(SelfAffectingThreading = true)]
- set { SetBackgroundNative(value); }
- }
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern bool IsBackgroundNative();
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void SetBackgroundNative(bool isBackground);
-
-
-
- public ThreadState ThreadState {
- get { return (ThreadState)GetThreadStateNative(); }
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern int GetThreadStateNative();
-
-
-
- [HostProtection(SharedState = true, ExternalThreading = true)]
- public static LocalDataStoreSlot AllocateDataSlot()
- {
- return LocalDataStoreManager.AllocateDataSlot();
- }
-
-
- [HostProtection(SharedState = true, ExternalThreading = true)]
- public static LocalDataStoreSlot AllocateNamedDataSlot(string name)
- {
- return LocalDataStoreManager.AllocateNamedDataSlot(name);
- }
-
-
- [HostProtection(SharedState = true, ExternalThreading = true)]
- public static LocalDataStoreSlot GetNamedDataSlot(string name)
- {
- return LocalDataStoreManager.GetNamedDataSlot(name);
- }
-
-
- [HostProtection(SharedState = true, ExternalThreading = true)]
- public static void FreeNamedDataSlot(string name)
- {
- LocalDataStoreManager.FreeNamedDataSlot(name);
- }
-
-
- [HostProtection(SharedState = true, ExternalThreading = true)]
- [ResourceExposure(ResourceScope.AppDomain)]
- public static object GetData(LocalDataStoreSlot slot)
- {
- LocalDataStoreManager.ValidateSlot(slot);
-
- LocalDataStore dls = GetDomainLocalStore();
- if (dls == null)
- return null;
-
- return dls.GetData(slot);
- }
-
-
- [HostProtection(SharedState = true, ExternalThreading = true)]
- [ResourceExposure(ResourceScope.AppDomain)]
- public static void SetData(LocalDataStoreSlot slot, object data)
- {
- LocalDataStore dls = GetDomainLocalStore();
-
-
- if (dls == null) {
- dls = LocalDataStoreManager.CreateLocalDataStore();
- SetDomainLocalStore(dls);
- }
-
- dls.SetData(slot, data);
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ResourceExposure(ResourceScope.AppDomain)]
- private static extern LocalDataStore GetDomainLocalStore();
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ResourceExposure(ResourceScope.AppDomain)]
- private static extern void SetDomainLocalStore(LocalDataStore dls);
-
-
- private static void RemoveDomainLocalStore(LocalDataStore dls)
- {
- if (dls != null)
- LocalDataStoreManager.DeleteLocalDataStore(dls);
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern bool nativeGetSafeCulture(Thread t, int appDomainId, bool isUI, ref CultureInfo safeCulture);
-
-
-
-
-
-
-
-
-
-
-
-
-
- public CultureInfo CurrentUICulture {
- get {
-
-
- if (m_CurrentUICulture == null) {
- return CultureInfo.UserDefaultUICulture;
- }
-
- CultureInfo culture = null;
-
- if (!nativeGetSafeCulture(this, GetDomainID(), true, ref culture) || culture == null) {
- return CultureInfo.UserDefaultUICulture;
- }
-
- return culture;
- }
-
- [HostProtection(ExternalThreading = true)]
- set {
- if (value == null) {
- throw new ArgumentNullException("value");
- }
-
-
-
- CultureInfo.VerifyCultureName(value, true);
-
- if (nativeSetThreadUILocale(value.LCID) == false) {
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidResourceCultureName", value.Name));
- }
-
- value.StartCrossDomainTracking();
- m_CurrentUICulture = value;
- }
- }
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern bool nativeSetThreadUILocale(int LCID);
-
-
-
-
-
-
-
-
-
-
-
-
-
- public CultureInfo CurrentCulture {
- get {
-
-
- if (m_CurrentCulture == null) {
- return CultureInfo.UserDefaultCulture;
- }
-
- CultureInfo culture = null;
-
- if (!nativeGetSafeCulture(this, GetDomainID(), false, ref culture) || culture == null) {
- return CultureInfo.UserDefaultCulture;
- }
-
- return culture;
- }
-
- [SecurityPermission(SecurityAction.Demand, ControlThread = true)]
- set {
- if (null == value) {
- throw new ArgumentNullException("value");
- }
- CultureInfo.CheckNeutral(value);
-
-
-
-
- CultureInfo.nativeSetThreadLocale(value.LCID);
-
- value.StartCrossDomainTracking();
- m_CurrentCulture = value;
- }
- }
-
-
- private int ReserveSlot()
- {
-
- if (m_ThreadStaticsBuckets == null) {
- BCLDebug.Assert(STATICS_BUCKET_SIZE % 32 == 0, "STATICS_BUCKET_SIZE should be a multiple of 32");
-
-
-
- object[][] newBuckets = new object[1][];
- SetIsThreadStaticsArray(newBuckets);
-
-
- newBuckets[0] = new object[STATICS_BUCKET_SIZE];
- SetIsThreadStaticsArray(newBuckets[0]);
-
- int[] newBits = new int[newBuckets.Length * STATICS_BUCKET_SIZE / 32];
-
-
- for (int i = 0; i < newBits.Length; i++) {
- newBits[i] = unchecked((int)4294967295u);
- }
-
-
-
- newBits[0] &= ~1;
-
-
- newBits[0] &= ~2;
-
-
-
-
- m_ThreadStaticsBits = newBits;
- m_ThreadStaticsBuckets = newBuckets;
-
- return 1;
- }
- int slot = FindSlot();
-
-
- if (slot == 0) {
-
- int oldLength = m_ThreadStaticsBuckets.Length;
- int oldLengthBits = m_ThreadStaticsBits.Length;
-
- int newLength = m_ThreadStaticsBuckets.Length + 1;
- object[][] newBuckets = new object[newLength][];
- SetIsThreadStaticsArray(newBuckets);
-
- int newLengthBits = newLength * STATICS_BUCKET_SIZE / 32;
- int[] newBits = new int[newLengthBits];
-
-
- Array.Copy(m_ThreadStaticsBuckets, newBuckets, m_ThreadStaticsBuckets.Length);
-
-
- for (int i = oldLength; i < newLength; i++) {
- newBuckets[i] = new object[STATICS_BUCKET_SIZE];
- SetIsThreadStaticsArray(newBuckets[i]);
- }
-
-
-
- Array.Copy(m_ThreadStaticsBits, newBits, m_ThreadStaticsBits.Length);
-
-
- for (int i = oldLengthBits; i < newLengthBits; i++) {
- newBits[i] = unchecked((int)4294967295u);
- }
-
-
- newBits[oldLengthBits] &= ~1;
-
-
-
- m_ThreadStaticsBits = newBits;
- m_ThreadStaticsBuckets = newBuckets;
-
- return oldLength * STATICS_BUCKET_SIZE;
- }
- return slot;
- }
-
- int FindSlot()
- {
- #if DEBUG
- BCLDebug.Assert(m_ThreadStaticsBits != null, "m_ThreadStaticsBits must already be initialized");
- if (m_ThreadStaticsBits.Length != 0) {
- BCLDebug.Assert(m_ThreadStaticsBuckets != null && m_ThreadStaticsBits.Length == m_ThreadStaticsBuckets.Length * STATICS_BUCKET_SIZE / 32, "m_ThreadStaticsBuckets must already be intialized");
- for (int j = 0; j < m_ThreadStaticsBuckets.Length; j++) {
- BCLDebug.Assert(m_ThreadStaticsBuckets[j] != null && m_ThreadStaticsBuckets[j].Length == STATICS_BUCKET_SIZE, "m_ThreadStaticsBuckets must already be initialized");
- }
- }
- #endif //DEBUG
-
- int slot = 0;
-
- int bits = 0;
- int i;
- bool bFound = false;
-
- if (m_ThreadStaticsBits.Length != 0 && m_ThreadStaticsBits.Length != m_ThreadStaticsBuckets.Length * STATICS_BUCKET_SIZE / 32)
- return 0;
-
- for (i = 0; i < m_ThreadStaticsBits.Length; i++) {
- bits = m_ThreadStaticsBits[i];
- if (bits != 0) {
- if ((bits & 65535) != 0) {
- bits = bits & 65535;
- }
- else {
- bits = (bits >> 16) & 65535;
- slot += 16;
- }
- if ((bits & 255) != 0) {
- bits = bits & 255;
- }
- else {
- slot += 8;
- bits = (bits >> 8) & 255;
- }
- int j;
- for (j = 0; j < 8; j++) {
- if ((bits & (1 << j)) != 0) {
- bFound = true;
- break;
- }
- }
- BCLDebug.Assert(j < 8, "Bad bits?");
- slot += j;
- m_ThreadStaticsBits[i] &= ~(1 << slot);
- break;
- }
- }
- if (bFound) {
- slot = slot + 32 * i;
- }
- BCLDebug.Assert(bFound || slot == 0, "Bad bits");
- return slot;
- }
-
-
-
-
- public static Context CurrentContext {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get { return CurrentThread.GetCurrentContextInternal(); }
- }
-
- internal Context GetCurrentContextInternal()
- {
- if (m_Context == null) {
- m_Context = Context.DefaultContext;
- }
- return m_Context;
- }
-
- [HostProtection(SharedState = true, ExternalThreading = true)]
- internal LogicalCallContext GetLogicalCallContext()
- {
- return ExecutionContext.LogicalCallContext;
- }
-
- [HostProtection(SharedState = true, ExternalThreading = true)]
- internal LogicalCallContext SetLogicalCallContext(LogicalCallContext callCtx)
- {
- LogicalCallContext oldCtx = ExecutionContext.LogicalCallContext;
- ExecutionContext.LogicalCallContext = callCtx;
- return oldCtx;
- }
-
- internal IllogicalCallContext GetIllogicalCallContext()
- {
- return ExecutionContext.IllogicalCallContext;
- }
-
-
- public static IPrincipal CurrentPrincipal {
- get {
- lock (CurrentThread) {
- IPrincipal principal = (IPrincipal)CallContext.Principal;
- if (principal == null) {
- principal = GetDomain().GetThreadPrincipal();
- CallContext.Principal = principal;
- }
- return principal;
- }
- }
-
- [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlPrincipal)]
- set { CallContext.Principal = value; }
- }
-
-
-
- private void SetPrincipalInternal(IPrincipal principal)
- {
- GetLogicalCallContext().SecurityData.Principal = principal;
- }
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern Context GetContextInternal(IntPtr id);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal extern object InternalCrossContextCallback(Context ctx, IntPtr ctxID, Int32 appDomainID, InternalCrossContextDelegate ftnToCall, object[] args);
-
- internal object InternalCrossContextCallback(Context ctx, InternalCrossContextDelegate ftnToCall, object[] args)
- {
- return InternalCrossContextCallback(ctx, ctx.InternalContextID, 0, ftnToCall, args);
- }
-
-
- private static object CompleteCrossContextCallback(InternalCrossContextDelegate ftnToCall, object[] args)
- {
- return ftnToCall(args);
- }
-
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern AppDomain GetDomainInternal();
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern AppDomain GetFastDomainInternal();
-
- public static AppDomain GetDomain()
- {
- if (CurrentThread.m_Context == null) {
- AppDomain ad;
- ad = GetFastDomainInternal();
- if (ad == null)
- ad = GetDomainInternal();
- return ad;
- }
- else {
- BCLDebug.Assert(GetDomainInternal() == CurrentThread.m_Context.AppDomain, "AppDomains on the managed & unmanaged threads should match");
- return CurrentThread.m_Context.AppDomain;
- }
- }
-
-
-
- public static int GetDomainID()
- {
- return GetDomain().GetId();
- }
-
-
-
-
- public string Name {
-
- get { return m_Name; }
- [HostProtection(ExternalThreading = true)]
- set {
- lock (this) {
- if (m_Name != null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_WriteOnce"));
- m_Name = value;
-
- InformThreadNameChangeEx(this, m_Name);
- }
- }
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern void InformThreadNameChangeEx(Thread t, string name);
-
- internal object AbortReason {
- get {
- object result = null;
- try {
- result = GetAbortReason();
- }
- catch (Exception e) {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ExceptionStateCrossAppDomain"), e);
- }
- return result;
- }
- set { SetAbortReason(value); }
- }
-
-
- [HostProtection(Synchronization = true, ExternalThreading = true)]
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- public static extern void BeginCriticalRegion();
-
-
- [HostProtection(Synchronization = true, ExternalThreading = true)]
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- public static extern void EndCriticalRegion();
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, ControlThread = true)]
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- public static extern void BeginThreadAffinity();
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, ControlThread = true)]
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- public static extern void EndThreadAffinity();
-
-
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static byte VolatileRead(ref byte address)
- {
- byte ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static short VolatileRead(ref short address)
- {
- short ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static int VolatileRead(ref int address)
- {
- int ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static long VolatileRead(ref long address)
- {
- long ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static sbyte VolatileRead(ref sbyte address)
- {
- sbyte ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static ushort VolatileRead(ref ushort address)
- {
- ushort ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static uint VolatileRead(ref uint address)
- {
- uint ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static IntPtr VolatileRead(ref IntPtr address)
- {
- IntPtr ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static UIntPtr VolatileRead(ref UIntPtr address)
- {
- UIntPtr ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static ulong VolatileRead(ref ulong address)
- {
- ulong ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static float VolatileRead(ref float address)
- {
- float ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static double VolatileRead(ref double address)
- {
- double ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static object VolatileRead(ref object address)
- {
- object ret = address;
- MemoryBarrier();
-
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref byte address, byte value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref short address, short value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref int address, int value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref long address, long value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref sbyte address, sbyte value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref ushort address, ushort value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref uint address, uint value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref IntPtr address, IntPtr value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref UIntPtr address, UIntPtr value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref ulong address, ulong value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref float address, float value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref double address, double value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
-
- public static void VolatileWrite(ref object address, object value)
- {
- MemoryBarrier();
-
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern void MemoryBarrier();
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void SetIsThreadStaticsArray(object o);
-
- private static LocalDataStoreMgr LocalDataStoreManager {
- get {
- if (s_LocalDataStoreMgr == null) {
- lock (s_SyncObject) {
- if (s_LocalDataStoreMgr == null)
- s_LocalDataStoreMgr = new LocalDataStoreMgr();
- }
- }
-
- return s_LocalDataStoreMgr;
- }
- }
-
- void _Thread.GetTypeInfoCount(out uint pcTInfo)
- {
- throw new NotImplementedException();
- }
-
- void _Thread.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
- {
- throw new NotImplementedException();
- }
-
- void _Thread.GetIDsOfNames( [In()]
- ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
- {
- throw new NotImplementedException();
- }
-
- void _Thread.Invoke(uint dispIdMember, [In()]
- ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
- {
- throw new NotImplementedException();
- }
-
-
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal extern void SetAbortReason(object o);
-
-
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal extern object GetAbortReason();
-
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal extern void ClearAbortReason();
-
- }
-
-
-
-
- [Serializable()]
- internal enum StackCrawlMark
- {
- LookForMe = 0,
- LookForMyCaller = 1,
- LookForMyCallersCaller = 2,
- LookForThread = 3
- }
-
- }