I'm working with a driver that was written by someone else. And I can see the following sequence (error checks are omitted.)
I'm also putting it all together in a simplified linear fashion. In the actual driver, some of these calls (at the end) are made from different threads:
WDF_WORKITEM_CONFIG config;
WDF_WORKITEM_CONFIG_INIT(&config, WorkItemCallback);
WDF_OBJECT_ATTRIBUTES attrib;
WDF_OBJECT_ATTRIBUTES_INIT(&attrib);
attrib.ParentObject = device;
WDFWORKITEM work_item;
WdfWorkItemCreate(&config, &attrib, &work_item);
WdfWorkItemEnqueue(work_item);
WdfObjectDelete(work_item);
WdfWorkItemFlush(work_item);
I'm wondering, if WdfWorkItemFlush
can be called after WdfObjectDelete
?