Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IDXGIDevice2::EnqueueSetEvent method

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


HRESULT EnqueueSetEvent(
  [in] HANDLE hEvent


hEvent [in]

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.


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.


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

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


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

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

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



Minimum supported client

Windows 8 and Platform Update for Windows 7 [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2012 and Platform Update for Windows Server 2008 R2 [desktop apps | Windows Store apps]

Minimum supported phone

Windows Phone 8





See also




© 2017 Microsoft