mscorlib(4.0.0.0) API with additions
ThreadPool.cs
6 using System.Security;
8 
9 namespace System.Threading
10 {
12  [__DynamicallyInvokable]
13  [HostProtection(SecurityAction.LinkDemand, Synchronization = true, ExternalThreading = true)]
14  public static class ThreadPool
15  {
21  [SecuritySafeCritical]
23  public static bool SetMaxThreads(int workerThreads, int completionPortThreads)
24  {
25  return SetMaxThreadsNative(workerThreads, completionPortThreads);
26  }
27 
31  [SecuritySafeCritical]
32  public static void GetMaxThreads(out int workerThreads, out int completionPortThreads)
33  {
34  GetMaxThreadsNative(out workerThreads, out completionPortThreads);
35  }
36 
43  [SecuritySafeCritical]
44  [SecurityPermission(SecurityAction.Demand, ControlThread = true)]
45  public static bool SetMinThreads(int workerThreads, int completionPortThreads)
46  {
47  return SetMinThreadsNative(workerThreads, completionPortThreads);
48  }
49 
55  [SecuritySafeCritical]
56  public static void GetMinThreads(out int workerThreads, out int completionPortThreads)
57  {
58  GetMinThreadsNative(out workerThreads, out completionPortThreads);
59  }
60 
64  [SecuritySafeCritical]
65  public static void GetAvailableThreads(out int workerThreads, out int completionPortThreads)
66  {
67  GetAvailableThreadsNative(out workerThreads, out completionPortThreads);
68  }
69 
79  [MethodImpl(MethodImplOptions.NoInlining)]
80  [SecuritySafeCritical]
81  [CLSCompliant(false)]
82  public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce)
83  {
84  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
85  return RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, compressStack: true);
86  }
87 
97  [MethodImpl(MethodImplOptions.NoInlining)]
98  [SecurityCritical]
99  [CLSCompliant(false)]
100  public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce)
101  {
102  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
103  return RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, compressStack: false);
104  }
105 
106  [SecurityCritical]
107  private static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce, ref StackCrawlMark stackMark, bool compressStack)
108  {
109  if (RemotingServices.IsTransparentProxy(waitObject))
110  {
111  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_WaitOnTransparentProxy"));
112  }
113  RegisteredWaitHandle registeredWaitHandle = new RegisteredWaitHandle();
114  if (callBack != null)
115  {
116  _ThreadPoolWaitOrTimerCallback threadPoolWaitOrTimerCallback = new _ThreadPoolWaitOrTimerCallback(callBack, state, compressStack, ref stackMark);
117  state = threadPoolWaitOrTimerCallback;
118  registeredWaitHandle.SetWaitObject(waitObject);
119  IntPtr handle = RegisterWaitForSingleObjectNative(waitObject, state, millisecondsTimeOutInterval, executeOnlyOnce, registeredWaitHandle, ref stackMark, compressStack);
120  registeredWaitHandle.SetHandle(handle);
121  return registeredWaitHandle;
122  }
123  throw new ArgumentNullException("WaitOrTimerCallback");
124  }
125 
135  [MethodImpl(MethodImplOptions.NoInlining)]
136  [SecuritySafeCritical]
137  public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, int millisecondsTimeOutInterval, bool executeOnlyOnce)
138  {
139  if (millisecondsTimeOutInterval < -1)
140  {
141  throw new ArgumentOutOfRangeException("millisecondsTimeOutInterval", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1"));
142  }
143  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
144  return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, compressStack: true);
145  }
146 
157  [MethodImpl(MethodImplOptions.NoInlining)]
158  [SecurityCritical]
159  public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, int millisecondsTimeOutInterval, bool executeOnlyOnce)
160  {
161  if (millisecondsTimeOutInterval < -1)
162  {
163  throw new ArgumentOutOfRangeException("millisecondsTimeOutInterval", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1"));
164  }
165  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
166  return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, compressStack: false);
167  }
168 
178  [MethodImpl(MethodImplOptions.NoInlining)]
179  [SecuritySafeCritical]
180  public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, long millisecondsTimeOutInterval, bool executeOnlyOnce)
181  {
182  if (millisecondsTimeOutInterval < -1)
183  {
184  throw new ArgumentOutOfRangeException("millisecondsTimeOutInterval", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1"));
185  }
186  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
187  return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, compressStack: true);
188  }
189 
200  [MethodImpl(MethodImplOptions.NoInlining)]
201  [SecurityCritical]
202  public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, long millisecondsTimeOutInterval, bool executeOnlyOnce)
203  {
204  if (millisecondsTimeOutInterval < -1)
205  {
206  throw new ArgumentOutOfRangeException("millisecondsTimeOutInterval", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1"));
207  }
208  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
209  return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, compressStack: false);
210  }
211 
222  [MethodImpl(MethodImplOptions.NoInlining)]
223  [SecuritySafeCritical]
224  public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, TimeSpan timeout, bool executeOnlyOnce)
225  {
226  long num = (long)timeout.TotalMilliseconds;
227  if (num < -1)
228  {
229  throw new ArgumentOutOfRangeException("timeout", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1"));
230  }
231  if (num > int.MaxValue)
232  {
233  throw new ArgumentOutOfRangeException("timeout", Environment.GetResourceString("ArgumentOutOfRange_LessEqualToIntegerMaxVal"));
234  }
235  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
236  return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)num, executeOnlyOnce, ref stackMark, compressStack: true);
237  }
238 
250  [MethodImpl(MethodImplOptions.NoInlining)]
251  [SecurityCritical]
252  public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, TimeSpan timeout, bool executeOnlyOnce)
253  {
254  long num = (long)timeout.TotalMilliseconds;
255  if (num < -1)
256  {
257  throw new ArgumentOutOfRangeException("timeout", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1"));
258  }
259  if (num > int.MaxValue)
260  {
261  throw new ArgumentOutOfRangeException("timeout", Environment.GetResourceString("ArgumentOutOfRange_LessEqualToIntegerMaxVal"));
262  }
263  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
264  return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)num, executeOnlyOnce, ref stackMark, compressStack: false);
265  }
266 
275  [MethodImpl(MethodImplOptions.NoInlining)]
276  [SecuritySafeCritical]
277  [__DynamicallyInvokable]
278  public static bool QueueUserWorkItem(WaitCallback callBack, object state)
279  {
280  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
281  return QueueUserWorkItemHelper(callBack, state, ref stackMark, compressStack: true);
282  }
283 
291  [MethodImpl(MethodImplOptions.NoInlining)]
292  [SecuritySafeCritical]
293  [__DynamicallyInvokable]
294  public static bool QueueUserWorkItem(WaitCallback callBack)
295  {
296  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
297  return QueueUserWorkItemHelper(callBack, null, ref stackMark, compressStack: true);
298  }
299 
310  [MethodImpl(MethodImplOptions.NoInlining)]
311  [SecurityCritical]
312  public static bool UnsafeQueueUserWorkItem(WaitCallback callBack, object state)
313  {
314  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
315  return QueueUserWorkItemHelper(callBack, state, ref stackMark, compressStack: false);
316  }
317 
318  [SecurityCritical]
319  private static bool QueueUserWorkItemHelper(WaitCallback callBack, object state, ref StackCrawlMark stackMark, bool compressStack)
320  {
321  bool result = true;
322  if (callBack != null)
323  {
324  EnsureVMInitialized();
325  try
326  {
327  return result;
328  }
329  finally
330  {
331  QueueUserWorkItemCallback callback = new QueueUserWorkItemCallback(callBack, state, compressStack, ref stackMark);
332  ThreadPoolGlobals.workQueue.Enqueue(callback, forceGlobal: true);
333  result = true;
334  }
335  }
336  throw new ArgumentNullException("WaitCallback");
337  }
338 
339  [SecurityCritical]
340  internal static void UnsafeQueueCustomWorkItem(IThreadPoolWorkItem workItem, bool forceGlobal)
341  {
342  EnsureVMInitialized();
343  try
344  {
345  }
346  finally
347  {
348  ThreadPoolGlobals.workQueue.Enqueue(workItem, forceGlobal);
349  }
350  }
351 
352  [SecurityCritical]
353  internal static bool TryPopCustomWorkItem(IThreadPoolWorkItem workItem)
354  {
355  if (!ThreadPoolGlobals.vmTpInitialized)
356  {
357  return false;
358  }
359  return ThreadPoolGlobals.workQueue.LocalFindAndPop(workItem);
360  }
361 
362  [SecurityCritical]
363  internal static IEnumerable<IThreadPoolWorkItem> GetQueuedWorkItems()
364  {
365  return EnumerateQueuedWorkItems(ThreadPoolWorkQueue.allThreadQueues.Current, ThreadPoolGlobals.workQueue.queueTail);
366  }
367 
368  internal static IEnumerable<IThreadPoolWorkItem> EnumerateQueuedWorkItems(ThreadPoolWorkQueue.WorkStealingQueue[] wsQueues, ThreadPoolWorkQueue.QueueSegment globalQueueTail)
369  {
370  if (wsQueues != null)
371  {
372  foreach (ThreadPoolWorkQueue.WorkStealingQueue workStealingQueue in wsQueues)
373  {
374  if (workStealingQueue == null || workStealingQueue.m_array == null)
375  {
376  continue;
377  }
378  IThreadPoolWorkItem[] items2 = workStealingQueue.m_array;
379  foreach (IThreadPoolWorkItem threadPoolWorkItem in items2)
380  {
381  if (threadPoolWorkItem != null)
382  {
383  yield return threadPoolWorkItem;
384  }
385  }
386  }
387  }
388  if (globalQueueTail == null)
389  {
390  yield break;
391  }
392  for (ThreadPoolWorkQueue.QueueSegment segment = globalQueueTail; segment != null; segment = segment.Next)
393  {
394  IThreadPoolWorkItem[] items = segment.nodes;
395  foreach (IThreadPoolWorkItem threadPoolWorkItem2 in items)
396  {
397  if (threadPoolWorkItem2 != null)
398  {
399  yield return threadPoolWorkItem2;
400  }
401  }
402  }
403  }
404 
405  [SecurityCritical]
406  internal static IEnumerable<IThreadPoolWorkItem> GetLocallyQueuedWorkItems()
407  {
408  return EnumerateQueuedWorkItems(new ThreadPoolWorkQueue.WorkStealingQueue[1]
409  {
410  ThreadPoolWorkQueueThreadLocals.threadLocals.workStealingQueue
411  }, null);
412  }
413 
414  [SecurityCritical]
415  internal static IEnumerable<IThreadPoolWorkItem> GetGloballyQueuedWorkItems()
416  {
417  return EnumerateQueuedWorkItems(null, ThreadPoolGlobals.workQueue.queueTail);
418  }
419 
420  private static object[] ToObjectArray(IEnumerable<IThreadPoolWorkItem> workitems)
421  {
422  int num = 0;
423  foreach (IThreadPoolWorkItem workitem in workitems)
424  {
425  num++;
426  }
427  object[] array = new object[num];
428  num = 0;
429  foreach (IThreadPoolWorkItem workitem2 in workitems)
430  {
431  if (num < array.Length)
432  {
433  array[num] = workitem2;
434  }
435  num++;
436  }
437  return array;
438  }
439 
440  [SecurityCritical]
441  internal static object[] GetQueuedWorkItemsForDebugger()
442  {
443  return ToObjectArray(GetQueuedWorkItems());
444  }
445 
446  [SecurityCritical]
447  internal static object[] GetGloballyQueuedWorkItemsForDebugger()
448  {
449  return ToObjectArray(GetGloballyQueuedWorkItems());
450  }
451 
452  [SecurityCritical]
453  internal static object[] GetLocallyQueuedWorkItemsForDebugger()
454  {
455  return ToObjectArray(GetLocallyQueuedWorkItems());
456  }
457 
458  [DllImport("QCall", CharSet = CharSet.Unicode)]
459  [SecurityCritical]
460  [SuppressUnmanagedCodeSecurity]
461  internal static extern bool RequestWorkerThread();
462 
463  [MethodImpl(MethodImplOptions.InternalCall)]
464  [SecurityCritical]
465  private unsafe static extern bool PostQueuedCompletionStatus(NativeOverlapped* overlapped);
466 
471  [SecurityCritical]
472  [CLSCompliant(false)]
473  public unsafe static bool UnsafeQueueNativeOverlapped(NativeOverlapped* overlapped)
474  {
475  return PostQueuedCompletionStatus(overlapped);
476  }
477 
478  [SecurityCritical]
479  private static void EnsureVMInitialized()
480  {
481  if (!ThreadPoolGlobals.vmTpInitialized)
482  {
483  InitializeVMTp(ref ThreadPoolGlobals.enableWorkerTracking);
484  ThreadPoolGlobals.vmTpInitialized = true;
485  }
486  }
487 
488  [MethodImpl(MethodImplOptions.InternalCall)]
489  [SecurityCritical]
490  private static extern bool SetMinThreadsNative(int workerThreads, int completionPortThreads);
491 
492  [MethodImpl(MethodImplOptions.InternalCall)]
493  [SecurityCritical]
494  private static extern bool SetMaxThreadsNative(int workerThreads, int completionPortThreads);
495 
496  [MethodImpl(MethodImplOptions.InternalCall)]
497  [SecurityCritical]
498  private static extern void GetMinThreadsNative(out int workerThreads, out int completionPortThreads);
499 
500  [MethodImpl(MethodImplOptions.InternalCall)]
501  [SecurityCritical]
502  private static extern void GetMaxThreadsNative(out int workerThreads, out int completionPortThreads);
503 
504  [MethodImpl(MethodImplOptions.InternalCall)]
505  [SecurityCritical]
506  private static extern void GetAvailableThreadsNative(out int workerThreads, out int completionPortThreads);
507 
508  [MethodImpl(MethodImplOptions.InternalCall)]
509  [SecurityCritical]
510  internal static extern bool NotifyWorkItemComplete();
511 
512  [MethodImpl(MethodImplOptions.InternalCall)]
513  [SecurityCritical]
514  internal static extern void ReportThreadStatus(bool isWorking);
515 
516  [SecuritySafeCritical]
517  internal static void NotifyWorkItemProgress()
518  {
519  if (!ThreadPoolGlobals.vmTpInitialized)
520  {
521  InitializeVMTp(ref ThreadPoolGlobals.enableWorkerTracking);
522  }
523  NotifyWorkItemProgressNative();
524  }
525 
526  [MethodImpl(MethodImplOptions.InternalCall)]
527  [SecurityCritical]
528  internal static extern void NotifyWorkItemProgressNative();
529 
530  [MethodImpl(MethodImplOptions.InternalCall)]
531  [SecurityCritical]
532  internal static extern bool IsThreadPoolHosted();
533 
534  [DllImport("QCall", CharSet = CharSet.Unicode)]
535  [SecurityCritical]
536  [SuppressUnmanagedCodeSecurity]
537  private static extern void InitializeVMTp(ref bool enableWorkerTracking);
538 
539  [MethodImpl(MethodImplOptions.InternalCall)]
540  [SecurityCritical]
541  private static extern IntPtr RegisterWaitForSingleObjectNative(WaitHandle waitHandle, object state, uint timeOutInterval, bool executeOnlyOnce, RegisteredWaitHandle registeredWaitHandle, ref StackCrawlMark stackMark, bool compressStack);
542 
548  [SecuritySafeCritical]
549  [Obsolete("ThreadPool.BindHandle(IntPtr) has been deprecated. Please use ThreadPool.BindHandle(SafeHandle) instead.", false)]
550  [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
551  public static bool BindHandle(IntPtr osHandle)
552  {
553  return BindIOCompletionCallbackNative(osHandle);
554  }
555 
562  [SecuritySafeCritical]
563  [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
564  public static bool BindHandle(SafeHandle osHandle)
565  {
566  if (osHandle == null)
567  {
568  throw new ArgumentNullException("osHandle");
569  }
570  bool flag = false;
571  bool success = false;
573  try
574  {
575  osHandle.DangerousAddRef(ref success);
576  return BindIOCompletionCallbackNative(osHandle.DangerousGetHandle());
577  }
578  finally
579  {
580  if (success)
581  {
582  osHandle.DangerousRelease();
583  }
584  }
585  }
586 
587  [MethodImpl(MethodImplOptions.InternalCall)]
588  [SecurityCritical]
589  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
590  private static extern bool BindIOCompletionCallbackNative(IntPtr fileHandle);
591  }
592 }
static unsafe bool UnsafeQueueNativeOverlapped(NativeOverlapped *overlapped)
Queues an overlapped I/O operation for execution.
Definition: ThreadPool.cs:473
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Describes a set of security permissions applied to code. This class cannot be inherited.
Ability to use certain advanced operations on threads.
Encapsulates operating system–specific objects that wait for exclusive access to shared resources.
Definition: WaitHandle.cs:15
Represents a handle that has been registered when calling M:System.Threading.ThreadPool....
static bool QueueUserWorkItem(WaitCallback callBack, object state)
Queues a method for execution, and specifies an object containing data to be used by the method....
Definition: ThreadPool.cs:278
Definition: __Canon.cs:3
The exception that is thrown when the value of an argument is outside the allowable range of values a...
double TotalMilliseconds
Gets the value of the current T:System.TimeSpan structure expressed in whole and fractional milliseco...
Definition: TimeSpan.cs:180
static bool UnsafeQueueUserWorkItem(WaitCallback callBack, object state)
Queues the specified delegate to the thread pool, but does not propagate the calling stack to the wor...
Definition: ThreadPool.cs:312
Exposes the enumerator, which supports a simple iteration over a collection of a specified type....
Definition: IEnumerable.cs:9
static void GetMinThreads(out int workerThreads, out int completionPortThreads)
Retrieves the minimum number of threads the thread pool creates on demand, as new requests are made,...
Definition: ThreadPool.cs:56
Represents a wrapper class for operating system handles. This class must be inherited.
Definition: SafeHandle.cs:12
Cer
Specifies a method's behavior when called within a constrained execution region.
Definition: Cer.cs:5
static bool SetMinThreads(int workerThreads, int completionPortThreads)
Sets the minimum number of threads the thread pool creates on demand, as new requests are made,...
Definition: ThreadPool.cs:45
void DangerousRelease()
Manually decrements the reference counter on a T:System.Runtime.InteropServices.SafeHandle instance.
SecurityAction
Specifies the security actions that can be performed using declarative security.
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
static void GetAvailableThreads(out int workerThreads, out int completionPortThreads)
Retrieves the difference between the maximum number of thread pool threads returned by the M:System....
Definition: ThreadPool.cs:65
static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce)
Registers a delegate to wait for a T:System.Threading.WaitHandle, specifying a 32-bit unsigned intege...
Definition: ThreadPool.cs:82
void DangerousAddRef(ref bool success)
Manually increments the reference counter on T:System.Runtime.InteropServices.SafeHandle instances.
static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, TimeSpan timeout, bool executeOnlyOnce)
Registers a delegate to wait for a T:System.Threading.WaitHandle, specifying a T:System....
Definition: ThreadPool.cs:224
A platform-specific type that is used to represent a pointer or a handle.
Definition: IntPtr.cs:14
delegate void WaitOrTimerCallback(object state, bool timedOut)
Represents a method to be called when a T:System.Threading.WaitHandle is signaled or times out.
static void PrepareConstrainedRegions()
Designates a body of code as a constrained execution region (CER).
static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, int millisecondsTimeOutInterval, bool executeOnlyOnce)
Registers a delegate to wait for a T:System.Threading.WaitHandle, using a 32-bit signed integer for t...
Definition: ThreadPool.cs:159
static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce)
Registers a delegate to wait for a T:System.Threading.WaitHandle, specifying a 32-bit unsigned intege...
Definition: ThreadPool.cs:100
static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, long millisecondsTimeOutInterval, bool executeOnlyOnce)
Registers a delegate to wait for a T:System.Threading.WaitHandle, specifying a 64-bit signed integer ...
Definition: ThreadPool.cs:202
MethodImplOptions
Defines the details of how a method is implemented.
CharSet
Dictates which character set marshaled strings should use.
Definition: CharSet.cs:7
static bool IsTransparentProxy(object proxy)
Returns a Boolean value that indicates whether the given object is a transparent proxy or a real obje...
IntPtr DangerousGetHandle()
Returns the value of the F:System.Runtime.InteropServices.SafeHandle.handle field.
Definition: SafeHandle.cs:89
static bool BindHandle(IntPtr osHandle)
Binds an operating system handle to the T:System.Threading.ThreadPool.
Definition: ThreadPool.cs:551
Represents a time interval.To browse the .NET Framework source code for this type,...
Definition: TimeSpan.cs:12
The exception that is thrown when a method call is invalid for the object's current state.
static bool QueueUserWorkItem(WaitCallback callBack)
Queues a method for execution. The method executes when a thread pool thread becomes available.
Definition: ThreadPool.cs:294
Consistency
Specifies a reliability contract.
Definition: Consistency.cs:5
static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, int millisecondsTimeOutInterval, bool executeOnlyOnce)
Registers a delegate to wait for a T:System.Threading.WaitHandle, specifying a 32-bit signed integer ...
Definition: ThreadPool.cs:137
static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, TimeSpan timeout, bool executeOnlyOnce)
Registers a delegate to wait for a T:System.Threading.WaitHandle, specifying a T:System....
Definition: ThreadPool.cs:252
delegate void WaitCallback(object state)
Represents a callback method to be executed by a thread pool thread.
SecurityPermissionFlag
Specifies access flags for the security permission object.
Provides several methods for using and publishing remoted objects and proxies. This class cannot be i...
static bool BindHandle(SafeHandle osHandle)
Binds an operating system handle to the T:System.Threading.ThreadPool.
Definition: ThreadPool.cs:564
static void GetMaxThreads(out int workerThreads, out int completionPortThreads)
Retrieves the number of requests to the thread pool that can be active concurrently....
Definition: ThreadPool.cs:32
Provides an explicit layout that is visible from unmanaged code and that will have the same layout as...
static bool SetMaxThreads(int workerThreads, int completionPortThreads)
Sets the number of requests to the thread pool that can be active concurrently. All requests above th...
Definition: ThreadPool.cs:23
Provides a pool of threads that can be used to execute tasks, post work items, process asynchronous I...
Definition: ThreadPool.cs:14
Provides a set of static methods and properties that provide support for compilers....
static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, long millisecondsTimeOutInterval, bool executeOnlyOnce)
Registers a delegate to wait for a T:System.Threading.WaitHandle, specifying a 64-bit signed integer ...
Definition: ThreadPool.cs:180