IDXGIDevice2::EnqueueSetEvent method (dxgi1_2.h)

Flushes any outstanding rendering commands and sets the specified event object to the signaled state after all previously submitted rendering commands complete.

Syntax

HRESULT EnqueueSetEvent(
  [in] HANDLE hEvent
);

Parameters

[in] hEvent

A handle to the event object. The CreateEvent or OpenEvent function returns this handle. All types of event objects (manual-reset, auto-reset, and so on) are supported.

The handle must have the EVENT_MODIFY_STATE access right. For more information about access rights, see Synchronization Object Security and Access Rights.

Return value

Returns S_OK if successful; otherwise, returns one of the following values:

  • E_OUTOFMEMORY if insufficient memory is available to complete the operation.
  • E_INVALIDARG if the parameter was validated and determined to be incorrect.
Platform Update for Windows 7:  On Windows 7 or Windows Server 2008 R2 with the Platform Update for Windows 7 installed, EnqueueSetEvent fails with E_NOTIMPL. For more info about the Platform Update for Windows 7, see Platform Update for Windows 7.

Remarks

EnqueueSetEvent calls the SetEvent function on the event object after all previously submitted rendering commands complete or the device is removed.

After an application calls EnqueueSetEvent, it can immediately call the WaitForSingleObject function to put itself to sleep until rendering commands complete.

You cannot use EnqueueSetEvent to determine work completion that is associated with presentation (IDXGISwapChain::Present); instead, we recommend that you use IDXGISwapChain::GetFrameStatistics.

Examples

The following example code shows how to use EnqueueSetEvent.

void BlockingFinish( IDXGIDevice2* pDevice ) 
{
    // Create a manual-reset event object. 
    hEvent = CreateEvent( 
        NULL,               // default security attributes
        TRUE,               // manual-reset event
        FALSE,              // initial state is nonsignaled
        FALSE
        ); 

    if (hEvent == NULL) 
    { 
        printf("CreateEvent failed (%d)\n", GetLastError());
        return;
    }

    pDevice->EnqueueSetEvent(hEvent);    

    DWORD dwWaitResult = WaitForSingleObject( 
        hEvent, // event handle
        INFINITE);    // indefinite wait

    switch (dwWaitResult) 
    {
        // Event object was signaled
        case WAIT_OBJECT_0: 
            // Commands completed
            break; 

        // An error occurred
        default: 
            printf("Wait error (%d)\n", GetLastError()); 
            return 0; 
    }

    CloseHandle(hEvent);
}

Requirements

Requirement Value
Minimum supported client Windows 8 and Platform Update for Windows 7 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 and Platform Update for Windows Server 2008 R2 [desktop apps | UWP apps]
Target Platform Windows
Header dxgi1_2.h
Library Dxgi.lib

See also

IDXGIDevice2