/// <summary> /// Queues a work item for processing on the managed thread pool /// </summary> /// <param name="callback">A WaitCallback representing the method to execute.</param> /// <param name="state">An object containing data to be used by the method.</param> /// <param name="ctx">Alternate execution context in which to run the thread.</param> /// <returns>Reference to queued thread</returns> /// <remarks> /// This differs from the normal thread pool QueueUserWorkItem function in that it does /// not return a success value determing if item was queued, but rather a reference to /// to the managed thread that was actually placed on the queue. /// </remarks> public static ManagedThread QueueUserWorkItem(ContextCallback callback, object state, ExecutionContext ctx) { if ((object)callback == null) { throw (new ArgumentNullException("callback")); } ManagedThread item = new ManagedThread(ThreadType.QueuedThread, callback, state, ctx); ManagedThreads.Queue(item); ThreadPool.QueueUserWorkItem(HandleItem); return(item); }
/// <summary> /// Queues a work item for processing on the managed thread pool /// </summary> /// <param name="callback">A WaitCallback representing the method to execute.</param> /// <param name="state">An object containing data to be used by the method.</param> /// <returns>Reference to queued thread</returns> /// <remarks> /// This differs from the normal thread pool QueueUserWorkItem function in that it does /// not return a success value determing if item was queued, but rather a reference to /// to the managed thread that was actually placed on the queue. /// </remarks> public static ManagedThread QueueUserWorkItem(ParameterizedThreadStart callback, object state) { if ((object)callback == null) { throw (new ArgumentNullException("callback")); } ManagedThread item = new ManagedThread(ThreadType.QueuedThread, callback, state, null); ManagedThreads.Queue(item); ThreadPool.QueueUserWorkItem(HandleItem); return(item); }
/// <summary> /// Queues a work item for processing on the managed thread pool /// </summary> /// <param name="callback">A WaitCallback representing the method to execute.</param> /// <returns>Reference to queued thread</returns> /// <remarks> /// This differs from the normal thread pool QueueUserWorkItem function in that it does /// not return a success value determing if item was queued, but rather a reference to /// to the managed thread that was actually placed on the queue. /// </remarks> public static ManagedThread QueueUserWorkItem(ThreadStart callback) { if ((object)callback == null) { throw (new ArgumentNullException(nameof(callback))); } ManagedThread item = new ManagedThread(ThreadType.QueuedThread, callback, null, null); ManagedThreads.Queue(item); ThreadPool.QueueUserWorkItem(HandleItem); return(item); }