Queues a method for execution, and specifies an object containing data to be used by the method. The method executes when a thread pool thread becomes available.
- callBack
- A System.Threading.WaitCallback representing the method to execute.
- state
- An object containing data to be used by the method.
true if the method is successfully queued; NotSupportedException is thrown if the work item could not be queued.
If the callback method requires complex data, you can define a class to contain the data.
Visual Basic users can omit the System.Threading.WaitCallback constructor, and simply use the AddressOf operator when passing the callback method to ThreadPool.QueueUserWorkItem(WaitCallback, object). Visual Basic automatically calls the correct delegate constructor.
In the .NET Framework version 2.0, the Thread.CurrentPrincipal property value is propagated to worker threads queued using the erload:System.Threading.ThreadPool.QueueUserWorkItem method. In earlier versions, the principal information is not propagated.