[Applies to KMDF and UMDF]
The WdfWorkItemCreate method creates a framework work-item object, which can subsequently be added to the system's work-item queue.
NTSTATUS WdfWorkItemCreate( PWDF_WORKITEM_CONFIG Config, PWDF_OBJECT_ATTRIBUTES Attributes, WDFWORKITEM *WorkItem );
A pointer to a caller-allocated WDF_OBJECT_ATTRIBUTES structure that specifies attributes for the work-item object.
A pointer to a variable that receives a handle to the new work-item object.
WdfWorkItemCreate returns STATUS_SUCCESS if the operation succeeds. Otherwise, this method might return one of the following values:
||An invalid parameter was supplied.|
||The work-item object's parent is not a device object or the ancestor of a device object.|
||There were insufficient system resources to create a work-item object.|
||The AutomaticSerialization member in the WDF_WORKITEM_CONFIG structure that the Config parameter points to is TRUE, but the parent object's execution level is not WdfExecutionLevelPassive.|
||The Attributes parameter was NULL, or the ParentObject member of the WDF_OBJECT_ATTRIBUTES structure that Attributes specifies was NULL.|
After a driver calls WdfWorkItemCreate to create a work item, it typically stores item-specific information in the context memory of the work-item object. The driver's EvtWorkItem callback function, which performs the work item's tasks, can access this information to determine the tasks that it must perform. (For more information about storing information in the context memory, see Framework Object Context Space.)
After storing work-item information, the driver must call WdfWorkItemEnqueue to add the work item to the system's work-item queue. When a system worker thread becomes available, the thread removes the work item from the queue and calls the EvtWorkItem callback function.
When the driver creates a work-item object, it must specify a parent object for the work-item object in the ParentObject member of the WDF_OBJECT_ATTRIBUTES structure. The parent object must be a framework device object or any object whose chain of parents leads to a framework device object. The framework will delete the work-item object when it deletes the device object.
The driver can retrieve a work item's parent object by calling WdfWorkItemGetParentObject.
For more information about work items, see Using Framework Work Items.
NTSTATUS status = STATUS_SUCCESS; PWORKER_ITEM_CONTEXT context; WDF_OBJECT_ATTRIBUTES attributes; WDF_WORKITEM_CONFIG workitemConfig; WDFWORKITEM hWorkItem;
|Minimum KMDF version||1.0|
|Minimum UMDF version||2.0|
|Header||wdfworkitem.h (include Wdf.h)|
|Library||Wdf01000.sys (KMDF); WUDFx02000.dll (UMDF)|
|DDI compliance rules||DriverCreate, KmdfIrql, KmdfIrql2|