MFPutWaitingWorkItem function (mfapi.h)

Queues a work item that waits for an event to be signaled.

Syntax

HRESULT MFPutWaitingWorkItem(
  [in]  HANDLE         hEvent,
  [in]  LONG           Priority,
  [in]  IMFAsyncResult *pResult,
  [out] MFWORKITEM_KEY *pKey
);

Parameters

[in] hEvent

A handle to an event object. To create an event object, call CreateEvent or CreateEventEx.

[in] Priority

The priority of the work item. Work items are performed in order of priority.

[in] pResult

A pointer to the IMFAsyncResult interface of an asynchronous result object. To create the result object, call MFCreateAsyncResult.

[out] pKey

Receives a key that can be used to cancel the wait. To cancel the wait, call MFCancelWorkItem and pass this key in the Key parameter.

This parameter can be NULL.

Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

This function enables a component to wait for an event without blocking the current thread.

The function puts a work item on the specified work queue. This work item waits for the event given in hEvent to be signaled. When the event is signaled, the work item invokes a callback. (The callback is contained in the result object given in pResult. For more information, see MFCreateAsyncResult).

The work item is dispatched on a work queue by the IMFAsyncCallback::GetParameters method of the callback. The work queue can be any of the following:

  • The default work queue (MFASYNC_CALLBACK_QUEUE_STANDARD).
  • The platform multithreaded queue (MFASYNC_CALLBACK_QUEUE_MULTITHREADED).
  • A multithreaded queue returned by the MFLockSharedWorkQueue function.
  • A serial queue created by the MFAllocateSerialWorkQueue function.
Do not use any of the following work queues: MFASYNC_CALLBACK_QUEUE_IO, MFASYNC_CALLBACK_QUEUE_LONG_FUNCTION, MFASYNC_CALLBACK_QUEUE_RT, or MFASYNC_CALLBACK_QUEUE_TIMER.

Requirements

Requirement Value
Minimum supported client Windows 8 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 [desktop apps | UWP apps]
Target Platform Windows
Header mfapi.h
DLL Mfplat.dll

See also

Media Foundation Functions

Work Queue and Threading Improvements

Work Queues