WdfWorkItemFlush method

[Applies to KMDF and UMDF]

The WdfWorkItemFlush method returns after a specified work item has been serviced.

Syntax


VOID WdfWorkItemFlush(
  [in]  WDFWORKITEM WorkItem
);

Parameters

WorkItem [in]

A handle to a framework work-item object that is obtained from a previous call to WdfWorkItemCreate.

Return value

None.

A bug check occurs if the driver supplies an invalid object handle.

Remarks

If your driver calls the WdfWorkItemFlush method, the method does not return until a system worker thread has removed the specified work item from the work-item queue and called the driver's EvtWorkItem callback function, and the EvtWorkItem callback function has subsequently returned after processing the work item.

Most drivers that use work items do not need to call WdfWorkItemFlush. A driver might call WdfWorkItemFlush if it must synchronize completion of work items with the removal of a remote I/O target. In this case, the driver can call WdfWorkItemFlush from within its EvtIoTargetQueryRemove callback function.

For more information about work items, see Using Framework Work Items.

Examples

The following code example is an EvtIoTargetQueryRemove callback function from the Toaster sample driver.


NTSTATUS
ToastMon_EvtIoTargetQueryRemove(
    WDFIOTARGET IoTarget
)
{
    PTARGET_DEVICE_INFO  targetDeviceInfo = NULL;
    //
    // Get the I/O target object's context.
    //
    targetDeviceInfo = GetTargetDeviceInfo(IoTarget);
    //
    // Ensure that the I/O target's work item
    // has been processed before closing the target.
    //
    WdfWorkItemFlush(targetDeviceInfo->WorkItem);
    WdfIoTargetCloseForQueryRemove(IoTarget);

    return STATUS_SUCCESS;
}

Requirements

Minimum KMDF version

1.0

Minimum UMDF version

2.0

Header

Wdfworkitem.h (include Wdf.h)

Library

Wdf01000.sys (KMDF);
WUDFx02000.dll (UMDF)

IRQL

PASSIVE_LEVEL

DDI compliance rules

DriverCreate, KmdfIrql, KmdfIrql2

See also

EvtWorkItem

 

 

Send comments about this topic to Microsoft

Mostrar:
© 2014 Microsoft