Creates work items that run in response to named events and semaphores. Also preallocates resources for work items that must be guaranteed the ability to run, even in circumstances of heavy (or full) resource allocation.
When work items are created using ThreadPool.RunAsync, the work item is created and submitted as a single operation. This is acceptable for most scenarios, but it is sometimes necessary to set aside resources for a work item in advance.
The PreallocatedWorkItem class constructs a work item ahead of time, putting the work item "on standby" so that it can be submitted to the thread pool when it's needed. This is useful in circumstances where the resources available to your app are completely allocated before the work item is needed - for example, calling a deallocation routine that uses a work item. If a work item has already been allocated, the resource deallocation routine can still be called and the PreallocatedWorkItem can still be submitted to the thread pool even if all resources are already in use.
Sometimes it is necessary to queue work items in response to named events or semaphores created by Win32 COM objects. You can run a Windows Runtime method in response to a named event or semaphore using a SignalNotifier object. This allows you to write Windows Runtime code that responds to events and signals sent using Win32 and COM for Windows Store apps, provided that the event or semaphore has a name. For example, the SignalNotifier can be used to work with Win32 code that's being ported to a Windows Store app.
Occasionally it is not possible to know the name of an event or semaphore, but your app still needs to respond to it; for example legacy code, and some well-known events and semaphores, still use waitable handles instead of names. ISignalableNotifier allows you to create ISignalNotifier objects registered with waitable handles.
The Windows.System.Threading.Core namespace has these types of members:
|PreallocatedWorkItem||A preallocated work item is constructed in advance of its submission to the thread pool, ensuring that the work item is constructed so that it can be submitted to the thread pool when necessary. For example, a PreallocatedWorkItem can be created in case it is needed for a resource deallocation routine, since the resource deallocation routine may be called in circumstances when not enough resources would be available to create the work item.|
|SignalNotifier||Runs a method when an event or semaphore is signaled. A timeout value can also be specified, causing the delegate to run after the time span has elapsed if the named event does not occur (or if the semaphore does not reach a signaled state).|
The Windows.System.Threading.Core namespace has these delegates.
|SignalHandler||Represents a method that is called when a signal notifier's attached event or semaphore is signaled, or when the optional timeout value has elapsed (whichever comes first).|
The Windows.System.Threading.Core namespace defines these interfaces.
Creates ISignalNotifier objects that invoke methods in response to an event or semaphore specified by handle.
Represents a method that is called when a signal notifier's attached event or semaphore is signaled, or when the optional timeout value has elapsed (whichever comes first).
Invokes a method when an event or semaphore is signaled, or when timeout occurs. Used when the event or semaphore can only be specified by handle.