13 [DebuggerTypeProxy(typeof(SystemThreadingCollections_BlockingCollectionDebugView<>))]
14 [DebuggerDisplay(
"Count = {Count}, Type = {m_collection}")]
15 [global::__DynamicallyInvokable]
21 private int m_boundedCapacity;
23 private const int NON_BOUNDED = -1;
29 private bool m_isDisposed;
35 private volatile int m_currentAdders;
37 private const int COMPLETE_ADDING_ON_MASK =
int.MinValue;
42 [global::__DynamicallyInvokable]
45 [global::__DynamicallyInvokable]
49 return m_boundedCapacity;
56 [global::__DynamicallyInvokable]
59 [global::__DynamicallyInvokable]
63 return m_currentAdders ==
int.MinValue;
70 [global::__DynamicallyInvokable]
73 [global::__DynamicallyInvokable]
88 [global::__DynamicallyInvokable]
91 [global::__DynamicallyInvokable]
102 [global::__DynamicallyInvokable]
105 [global::__DynamicallyInvokable]
116 [global::__DynamicallyInvokable]
119 [global::__DynamicallyInvokable]
129 [global::__DynamicallyInvokable]
138 [global::__DynamicallyInvokable]
150 [global::__DynamicallyInvokable]
153 if (boundedCapacity < 1)
155 throw new ArgumentOutOfRangeException(
"boundedCapacity", boundedCapacity, SR.GetString(
"BlockingCollection_ctor_BoundedCapacityRange"));
157 if (collection ==
null)
161 int count = collection.Count;
162 if (count > boundedCapacity)
164 throw new ArgumentException(SR.GetString(
"BlockingCollection_ctor_CountMoreThanCapacity"));
166 Initialize(collection, boundedCapacity, count);
172 [global::__DynamicallyInvokable]
175 if (collection ==
null)
179 Initialize(collection, -1, collection.Count);
184 m_collection = collection;
185 m_boundedCapacity = boundedCapacity;
186 m_isDisposed =
false;
189 if (boundedCapacity == -1)
195 m_freeNodes =
new SemaphoreSlim(boundedCapacity - collectionCount);
204 [global::__DynamicallyInvokable]
216 [global::__DynamicallyInvokable]
219 TryAddWithNoTimeValidation(item, -1, cancellationToken);
227 [global::__DynamicallyInvokable]
241 [global::__DynamicallyInvokable]
244 ValidateTimeout(timeout);
256 [global::__DynamicallyInvokable]
257 public bool TryAdd(T item,
int millisecondsTimeout)
259 ValidateMillisecondsTimeout(millisecondsTimeout);
260 return TryAddWithNoTimeValidation(item, millisecondsTimeout,
default(
CancellationToken));
273 [global::__DynamicallyInvokable]
276 ValidateMillisecondsTimeout(millisecondsTimeout);
277 return TryAddWithNoTimeValidation(item, millisecondsTimeout, cancellationToken);
280 private bool TryAddWithNoTimeValidation(T item,
int millisecondsTimeout,
CancellationToken cancellationToken)
292 if (m_freeNodes !=
null)
297 flag = m_freeNodes.
Wait(0);
298 if (!flag && millisecondsTimeout != 0)
301 flag = m_freeNodes.
Wait(millisecondsTimeout, cancellationTokenSource.
Token);
304 catch (OperationCanceledException)
308 throw new OperationCanceledException(SR.GetString(
"Common_OperationCanceled"), cancellationToken);
310 throw new InvalidOperationException(SR.GetString(
"BlockingCollection_Add_ConcurrentCompleteAdd"));
314 cancellationTokenSource?.
Dispose();
322 int currentAdders = m_currentAdders;
323 if ((currentAdders &
int.MinValue) != 0)
326 while (m_currentAdders !=
int.MinValue)
330 throw new InvalidOperationException(SR.GetString(
"BlockingCollection_Completed"));
344 flag2 = m_collection.TryAdd(item);
348 if (m_freeNodes !=
null)
356 throw new InvalidOperationException(SR.GetString(
"BlockingCollection_Add_Failed"));
373 [global::__DynamicallyInvokable]
389 [global::__DynamicallyInvokable]
392 if (!
TryTake(out
T item, -1, cancellationToken))
405 [global::__DynamicallyInvokable]
421 [global::__DynamicallyInvokable]
424 ValidateTimeout(timeout);
437 [global::__DynamicallyInvokable]
438 public bool TryTake(out T item,
int millisecondsTimeout)
440 ValidateMillisecondsTimeout(millisecondsTimeout);
455 [global::__DynamicallyInvokable]
458 ValidateMillisecondsTimeout(millisecondsTimeout);
459 return TryTakeWithNoTimeValidation(out item, millisecondsTimeout, cancellationToken,
null);
478 flag = m_occupiedNodes.
Wait(0);
479 if (!flag && millisecondsTimeout != 0)
481 if (combinedTokenSource ==
null)
485 flag = m_occupiedNodes.
Wait(millisecondsTimeout, cancellationTokenSource.
Token);
488 catch (OperationCanceledException)
492 throw new OperationCanceledException(SR.GetString(
"Common_OperationCanceled"), cancellationToken);
498 if (cancellationTokenSource !=
null && combinedTokenSource ==
null)
500 cancellationTokenSource.
Dispose();
510 flag2 = m_collection.TryTake(out item);
514 throw new InvalidOperationException(SR.GetString(
"BlockingCollection_Take_CollectionModified"));
522 if (m_freeNodes !=
null)
533 CancelWaitingConsumers();
549 [global::__DynamicallyInvokable]
566 [global::__DynamicallyInvokable]
569 return TryAddToAny(collections, item, -1, cancellationToken);
581 [global::__DynamicallyInvokable]
598 [global::__DynamicallyInvokable]
601 ValidateTimeout(timeout);
616 [global::__DynamicallyInvokable]
619 ValidateMillisecondsTimeout(millisecondsTimeout);
636 [global::__DynamicallyInvokable]
639 ValidateMillisecondsTimeout(millisecondsTimeout);
640 return TryAddToAnyCore(collections, item, millisecondsTimeout, cancellationToken);
645 ValidateCollectionsArray(collections, isAddOperation:
true);
646 int num = millisecondsTimeout;
648 if (millisecondsTimeout != -1)
652 int num2 = TryAddToAnyFast(collections, item);
658 List<WaitHandle> handles = GetHandles(collections, externalCancellationToken, isAddOperation:
true, out cancellationTokens);
659 while (millisecondsTimeout == -1 || num >= 0)
673 throw new ArgumentException(SR.GetString(
"BlockingCollection_CantAddAnyWhenCompleted"),
"collections");
680 if (collections[num2].
TryAdd(item))
684 if (millisecondsTimeout != -1)
686 num = UpdateTimeOut(startTime, millisecondsTimeout);
692 private static int TryAddToAnyFast(BlockingCollection<T>[] collections, T item)
694 for (
int i = 0; i < collections.Length; i++)
696 if (collections[i].m_freeNodes ==
null)
698 collections[i].TryAdd(item);
709 list2.
Add(externalCancellationToken);
712 for (
int i = 0; i < collections.Length; i++)
714 if (collections[i].m_freeNodes !=
null)
717 list2.
Add(collections[i].m_ProducersCancellationTokenSource.
Token);
723 for (
int j = 0; j < collections.Length; j++)
728 list2.
Add(collections[j].m_ConsumersCancellationTokenSource.
Token);
732 cancellationTokens = list2.
ToArray();
736 private static int UpdateTimeOut(uint startTime,
int originalWaitMillisecondsTimeout)
738 if (originalWaitMillisecondsTimeout == 0)
742 uint num = (uint)(Environment.TickCount - (
int)startTime);
743 if (num >
int.MaxValue)
747 int num2 = originalWaitMillisecondsTimeout - (int)num;
764 [global::__DynamicallyInvokable]
781 [global::__DynamicallyInvokable]
784 return TryTakeFromAnyCore(collections, out item, -1, isTakeOperation:
true, cancellationToken);
796 [global::__DynamicallyInvokable]
813 [global::__DynamicallyInvokable]
816 ValidateTimeout(timeout);
831 [global::__DynamicallyInvokable]
834 ValidateMillisecondsTimeout(millisecondsTimeout);
835 return TryTakeFromAnyCore(collections, out item, millisecondsTimeout, isTakeOperation:
false,
CancellationToken.
None);
851 [global::__DynamicallyInvokable]
854 ValidateMillisecondsTimeout(millisecondsTimeout);
855 return TryTakeFromAnyCore(collections, out item, millisecondsTimeout, isTakeOperation:
false, cancellationToken);
860 ValidateCollectionsArray(collections, isAddOperation:
false);
861 for (
int i = 0; i < collections.Length; i++)
863 if (!collections[i].
IsCompleted && collections[i].m_occupiedNodes.
CurrentCount > 0 && collections[i].TryTake(out item))
868 return TryTakeFromAnyCoreSlow(collections, out item, millisecondsTimeout, isTakeOperation, externalCancellationToken);
871 private static int TryTakeFromAnyCoreSlow(BlockingCollection<T>[] collections, out T item,
int millisecondsTimeout,
bool isTakeOperation,
CancellationToken externalCancellationToken)
873 int num = millisecondsTimeout;
875 if (millisecondsTimeout != -1)
877 startTime = (uint)Environment.TickCount;
879 while (millisecondsTimeout == -1 || num >= 0)
882 List<WaitHandle> handles = GetHandles(collections, externalCancellationToken, isAddOperation:
false, out cancellationTokens);
883 if (handles.
Count == 0 && isTakeOperation)
885 throw new ArgumentException(SR.GetString(
"BlockingCollection_CantTakeAnyWhenAllDone"),
"collections");
887 if (handles.
Count == 0)
897 throw new OperationCanceledException(SR.GetString(
"Common_OperationCanceled"), externalCancellationToken);
905 if (collections.Length != handles.
Count - 1)
907 for (
int i = 0; i < collections.Length; i++)
916 if (collections[num2].
TryTake(out item))
922 if (millisecondsTimeout != -1)
924 num = UpdateTimeOut(startTime, millisecondsTimeout);
933 [global::__DynamicallyInvokable]
944 int currentAdders = m_currentAdders;
945 if ((currentAdders &
int.MinValue) != 0)
948 while (m_currentAdders !=
int.MinValue)
961 while (m_currentAdders !=
int.MinValue)
967 CancelWaitingConsumers();
969 CancelWaitingProducers();
972 private void CancelWaitingConsumers()
974 m_ConsumersCancellationTokenSource.
Cancel();
977 private void CancelWaitingProducers()
979 m_ProducersCancellationTokenSource.
Cancel();
983 [global::__DynamicallyInvokable]
992 [global::__DynamicallyInvokable]
993 protected virtual void Dispose(
bool disposing)
997 if (m_freeNodes !=
null)
1002 m_isDisposed =
true;
1009 [global::__DynamicallyInvokable]
1013 return m_collection.ToArray();
1023 [global::__DynamicallyInvokable]
1036 [global::__DynamicallyInvokable]
1040 T[] array2 = m_collection.ToArray();
1043 Array.
Copy(array2, 0, array, index, array2.Length);
1053 catch (ArgumentException)
1055 throw new ArgumentException(SR.GetString(
"BlockingCollection_CopyTo_TooManyElems"),
"index");
1057 catch (RankException)
1059 throw new ArgumentException(SR.GetString(
"BlockingCollection_CopyTo_MultiDim"),
"array");
1061 catch (InvalidCastException)
1063 throw new ArgumentException(SR.GetString(
"BlockingCollection_CopyTo_IncorrectType"),
"array");
1065 catch (ArrayTypeMismatchException)
1067 throw new ArgumentException(SR.GetString(
"BlockingCollection_CopyTo_IncorrectType"),
"array");
1074 [global::__DynamicallyInvokable]
1085 [global::__DynamicallyInvokable]
1094 if (TryTakeWithNoTimeValidation(out
T item, -1, cancellationToken, linkedTokenSource))
1109 [global::__DynamicallyInvokable]
1113 return m_collection.GetEnumerator();
1119 [global::__DynamicallyInvokable]
1125 private static void ValidateCollectionsArray(BlockingCollection<T>[] collections,
bool isAddOperation)
1127 if (collections ==
null)
1131 if (collections.Length < 1)
1133 throw new ArgumentException(SR.GetString(
"BlockingCollection_ValidateCollectionsArray_ZeroSize"),
"collections");
1135 if ((!IsSTAThread && collections.Length > 63) || (IsSTAThread && collections.Length > 62))
1137 throw new ArgumentOutOfRangeException(
"collections", SR.GetString(
"BlockingCollection_ValidateCollectionsArray_LargeSize"));
1142 if (num < collections.Length)
1144 if (collections[num] ==
null)
1146 throw new ArgumentException(SR.GetString(
"BlockingCollection_ValidateCollectionsArray_NullElems"),
"collections");
1148 if (collections[num].m_isDisposed)
1150 throw new ObjectDisposedException(
"collections", SR.GetString(
"BlockingCollection_ValidateCollectionsArray_DispElems"));
1161 throw new ArgumentException(SR.GetString(
"BlockingCollection_CantAddAnyWhenCompleted"),
"collections");
1164 private static void ValidateTimeout(TimeSpan timeout)
1166 long num = (long)timeout.TotalMilliseconds;
1167 if ((num < 0 || num >
int.MaxValue) && num != -1)
1169 throw new ArgumentOutOfRangeException(
"timeout", timeout,
string.Format(
CultureInfo.
InvariantCulture, SR.GetString(
"BlockingCollection_TimeoutInvalid"),
new object[1]
1176 private static void ValidateMillisecondsTimeout(
int millisecondsTimeout)
1178 if (millisecondsTimeout < 0 && millisecondsTimeout != -1)
1180 throw new ArgumentOutOfRangeException(
"millisecondsTimeout", millisecondsTimeout,
string.Format(
CultureInfo.
InvariantCulture, SR.GetString(
"BlockingCollection_TimeoutInvalid"),
new object[1]
1187 private void CheckDisposed()
1191 throw new ObjectDisposedException(
"BlockingCollection", SR.GetString(
"BlockingCollection_Disposed"));
static Thread CurrentThread
Gets the currently running thread.
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
Represents a lightweight alternative to T:System.Threading.Semaphore that limits the number of thread...
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
Waits for any of the elements in the specified array to receive a signal, using a 32-bit signed integ...
Propagates notification that operations should be canceled.
static int AddToAny(BlockingCollection< T >[] collections, T item, CancellationToken cancellationToken)
Adds the specified item to any one of the specified T:System.Collections.Concurrent....
Encapsulates operating system–specific objects that wait for exclusive access to shared resources.
static int TakeFromAny(BlockingCollection< T >[] collections, out T item)
Takes an item from any one of the specified T:System.Collections.Concurrent.BlockingCollection`1 inst...
void ThrowIfCancellationRequested()
Throws a T:System.OperationCanceledException if this token has had cancellation requested.
static int TryAddToAny(BlockingCollection< T >[] collections, T item)
Tries to add the specified item to any one of the specified T:System.Collections.Concurrent....
int Count
Gets the number of elements contained in the T:System.Collections.Generic.List`1.
void CompleteAdding()
Marks the T:System.Collections.Concurrent.BlockingCollection`1 instances as not accepting any more ad...
void Reset()
Resets the spin counter.
void RemoveAt(int index)
Removes the element at the specified index of the T:System.Collections.Generic.List`1.
static void SuppressFinalize(object obj)
Requests that the common language runtime not call the finalizer for the specified object.
IEnumerable< T > GetConsumingEnumerable(CancellationToken cancellationToken)
Provides a consuming T:System.Collections.Generic.IEnumerable`1 for items in the collection.
Provides support for spin-based waiting.
bool TryAdd(T item, int millisecondsTimeout)
Tries to add the specified item to the T:System.Collections.Concurrent.BlockingCollection`1 within th...
static CancellationTokenSource CreateLinkedTokenSource(CancellationToken token1, CancellationToken token2)
Creates a T:System.Threading.CancellationTokenSource that will be in the canceled state when any of t...
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
void Cancel()
Communicates a request for cancellation.
void Add(T item, CancellationToken cancellationToken)
Adds the item to the T:System.Collections.Concurrent.BlockingCollection`1.
static int TryTakeFromAny(BlockingCollection< T >[] collections, out T item, int millisecondsTimeout)
Tries to remove an item from any one of the specified T:System.Collections.Concurrent....
int Release()
Releases the T:System.Threading.SemaphoreSlim object once.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
T [] ToArray()
Copies the items from the T:System.Collections.Concurrent.BlockingCollection`1 instance into a new ar...
double TotalMilliseconds
Gets the value of the current T:System.TimeSpan structure expressed in whole and fractional milliseco...
CancellationToken Token
Gets the T:System.Threading.CancellationToken associated with this T:System.Threading....
T Take()
Removes an item from the T:System.Collections.Concurrent.BlockingCollection`1.
void Dispose()
Releases all resources used by the current instance of the T:System.Threading.SemaphoreSlim class.
Represents a strongly-typed, read-only collection of elements.
void Add(T item)
Adds the item to the T:System.Collections.Concurrent.BlockingCollection`1.
int Count
Gets the number of items contained in the T:System.Collections.Concurrent.BlockingCollection`1.
static int TryTakeFromAny(BlockingCollection< T >[] collections, out T item, int millisecondsTimeout, CancellationToken cancellationToken)
Tries to remove an item from any one of the specified T:System.Collections.Concurrent....
bool IsCancellationRequested
Gets whether cancellation has been requested for this token.
int CurrentCount
Gets the number of remaining threads that can enter the T:System.Threading.SemaphoreSlim object.
void Dispose()
Releases all resources used by the current instance of the T:System.Collections.Concurrent....
Defines methods to manipulate generic collections.
BlockingCollection(int boundedCapacity)
Initializes a new instance of the T:System.Collections.Concurrent.BlockingCollection`1 class with the...
Provides blocking and bounding capabilities for thread-safe collections that implement T:System....
WaitHandle AvailableWaitHandle
Returns a T:System.Threading.WaitHandle that can be used to wait on the semaphore.
void Add(T item)
Adds an object to the end of the T:System.Collections.Generic.List`1.
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
SecurityAction
Specifies the security actions that can be performed using declarative security.
Provides information about, and means to manipulate, the current environment and platform....
virtual void Dispose(bool disposing)
Releases resources used by the T:System.Collections.Concurrent.BlockingCollection`1 instance.
static int TakeFromAny(BlockingCollection< T >[] collections, out T item, CancellationToken cancellationToken)
Takes an item from any one of the specified T:System.Collections.Concurrent.BlockingCollection`1 inst...
IEnumerable< T > GetConsumingEnumerable()
Provides a consuming T:System.Collections.Generic.IEnumerator`1 for items in the collection.
ApartmentState GetApartmentState()
Returns an T:System.Threading.ApartmentState value indicating the apartment state.
T Take(CancellationToken cancellationToken)
Removes an item from the T:System.Collections.Concurrent.BlockingCollection`1.
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
static int TryAddToAny(BlockingCollection< T >[] collections, T item, TimeSpan timeout)
Tries to add the specified item to any one of the specified T:System.Collections.Concurrent....
void Dispose()
Releases all resources used by the current instance of the T:System.Threading.CancellationTokenSource...
static int TryTakeFromAny(BlockingCollection< T >[] collections, out T item)
Tries to remove an item from any one of the specified T:System.Collections.Concurrent....
void Wait()
Blocks the current thread until it can enter the T:System.Threading.SemaphoreSlim.
void CopyTo(T[] array, int index)
Copies all of the items in the T:System.Collections.Concurrent.BlockingCollection`1 instance to a com...
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
bool IsSynchronized
Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (threa...
static int TickCount
Gets the number of milliseconds elapsed since the system started.
bool TryAdd(T item)
Tries to add the specified item to the T:System.Collections.Concurrent.BlockingCollection`1.
int BoundedCapacity
Gets the bounded capacity of this T:System.Collections.Concurrent.BlockingCollection`1 instance.
static int TryTakeFromAny(BlockingCollection< T >[] collections, out T item, TimeSpan timeout)
Tries to remove an item from any one of the specified T:System.Collections.Concurrent....
bool IsCompleted
Gets whether this T:System.Collections.Concurrent.BlockingCollection`1 has been marked as complete fo...
bool IsAddingCompleted
Gets whether this T:System.Collections.Concurrent.BlockingCollection`1 has been marked as complete fo...
IEnumerator GetEnumerator()
Returns an enumerator that iterates through a collection.
static CancellationToken None
Returns an empty T:System.Threading.CancellationToken value.
static int TryAddToAny(BlockingCollection< T >[] collections, T item, int millisecondsTimeout)
Tries to add the specified item to any one of the specified T:System.Collections.Concurrent....
bool TryTake(out T item, int millisecondsTimeout)
Tries to remove an item from the T:System.Collections.Concurrent.BlockingCollection`1 in the specifie...
Defines methods to manipulate thread-safe collections intended for producer/consumer usage....
Controls the system garbage collector, a service that automatically reclaims unused memory.
The exception that is thrown when one of the arguments provided to a method is not valid.
WaitHandle WaitHandle
Gets a T:System.Threading.WaitHandle that is signaled when the token is canceled.
bool TryAdd(T item, int millisecondsTimeout, CancellationToken cancellationToken)
Tries to add the specified item to the T:System.Collections.Concurrent.BlockingCollection`1 within th...
bool TryTake(out T item)
Tries to remove an item from the T:System.Collections.Concurrent.BlockingCollection`1.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
BlockingCollection()
Initializes a new instance of the T:System.Collections.Concurrent.BlockingCollection`1 class without ...
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
The exception that is thrown in a thread upon cancellation of an operation that the thread was execut...
void SpinOnce()
Performs a single spin.
Creates or manipulates threads other than its own, which might be harmful to the host.
Represents a time interval.To browse the .NET Framework source code for this type,...
Signals to a T:System.Threading.CancellationToken that it should be canceled.
BlockingCollection(IProducerConsumerCollection< T > collection, int boundedCapacity)
Initializes a new instance of the T:System.Collections.Concurrent.BlockingCollection`1 class with the...
static int TryAddToAny(BlockingCollection< T >[] collections, T item, int millisecondsTimeout, CancellationToken cancellationToken)
Tries to add the specified item to any one of the specified T:System.Collections.Concurrent....
Represents a thread-safe first in-first out (FIFO) collection.
The exception that is thrown when a method call is invalid for the object's current state.
bool TryTake(out T item, int millisecondsTimeout, CancellationToken cancellationToken)
Tries to remove an item from the T:System.Collections.Concurrent.BlockingCollection`1 in the specifie...
bool TryAdd(T item, TimeSpan timeout)
Tries to add the specified item to the T:System.Collections.Concurrent.BlockingCollection`1.
static int Decrement(ref int location)
Decrements a specified variable and stores the result, as an atomic operation.
Provides information about a specific culture (called a locale for unmanaged code development)....
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
bool IsCancellationRequested
Gets whether cancellation has been requested for this T:System.Threading.CancellationTokenSource.
Defines size, enumerators, and synchronization methods for all nongeneric collections.
bool TryTake(out T item, TimeSpan timeout)
Tries to remove an item from the T:System.Collections.Concurrent.BlockingCollection`1 in the specifie...
void CopyTo(Array array, int index)
Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a parti...
T [] ToArray()
Copies the elements of the T:System.Collections.Generic.List`1 to a new array.
BlockingCollection(IProducerConsumerCollection< T > collection)
Initializes a new instance of the T:System.Collections.Concurrent.BlockingCollection`1 class without ...
Provides atomic operations for variables that are shared by multiple threads.
static int AddToAny(BlockingCollection< T >[] collections, T item)
Adds the specified item to any one of the specified T:System.Collections.Concurrent....
Supports a simple iteration over a non-generic collection.
ApartmentState
Specifies the apartment state of a T:System.Threading.Thread.
Creates and controls a thread, sets its priority, and gets its status.