> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SetEventOnCompletion

> 펜스가 특정 값에 도달할 때 발생시킬 이벤트를 지정합니다. (ID3D12Fence.SetEventOnCompletion)

펜스가 특정 값에 도달할 때 발생하는 이벤트를 지정합니다.

## 구문

```cpp theme={null}
HRESULT SetEventOnCompletion(
    UINT64 Value,
    HANDLE hEvent
)
```

### 매개 변수

*Value*\
형식: UINT64

이벤트가 신호를 받을 펜스 값입니다.

*hEvent*\
형식: HANDLE

이벤트 객체에 대한 핸들입니다.

### 반환 값

형식: HRESULT

커널 구성 요소에 이벤트를 목록에 저장할 충분한 메모리가 없는 경우 이 메서드는 **E\_OUTOFMEMORY**를 반환합니다. 다른 가능한 반환 값은 [Direct3D 12 반환 코드](https://learn.microsoft.com/en-us/windows/win32/direct3d12/d3d12-graphics-reference-returnvalues)를 참조하세요.

## 설명

이벤트가 트리거되기 전에 여러 펜스를 지정하려면 [SetEventOnMultipleFenceCompletion](/reference/graphics/d3d12/interfaces/id3d12device1/methods/id3d12device1_seteventonmultiplefencecompletion_public)을 참조하세요.

*hEvent*가 null 핸들이면, 이 API는 지정된 펜스 값에 도달할 때까지 반환되지 않습니다.

이 메서드는 여러 스레드에서 동시에 안전하게 호출할 수 있습니다.

## 예제

[D3D12Multithreading](https://learn.microsoft.com/en-us/windows/win32/direct3d12/working-samples) 샘플은 다음과 같이 **ID3D12Fence::SetEventOnCompletion**을 사용합니다:

```cpp theme={null}
// Wait for the command list to execute; we are reusing the same command
// list in our main loop but for now, we just want to wait for setup to
// complete before continuing.

// Signal and increment the fence value.
const UINT64 fenceToWaitFor = m_fenceValue;
ThrowIfFailed(m_commandQueue->Signal(m_fence.Get(), fenceToWaitFor));
m_fenceValue++;

// Wait until the fence is completed.
ThrowIfFailed(m_fence->SetEventOnCompletion(fenceToWaitFor, m_fenceEvent));
WaitForSingleObject(m_fenceEvent, INFINITE);
```

[Direct3D 12 참조의 예제 코드](https://learn.microsoft.com/en-us/windows/win32/direct3d12/notes-on-example-code)를 참조하세요.

## 요구 사항

**헤더:** d3d12\_xs.h 또는 d3d12\_x.h\
**라이브러리:** d3d12\_xs.lib 또는 d3d12\_x.lib\
**지원 플랫폼**: XBOX Series 콘솔 및 XBOX One 제품군

## 함께 보기

[ID3D12Fence](/reference/graphics/d3d12/interfaces/id3d12fence/id3d12fence_public)

[다중 엔진 동기화](https://learn.microsoft.com/en-us/windows/win32/direct3d12/user-mode-heap-synchronization)


## Related topics

- [SetEventOnMultipleFenceCompletion](/ko/reference/graphics/d3d12/interfaces/id3d12device1/methods/id3d12device1_seteventonmultiplefencecompletion_public.md)
- [DirectStorage 개요](/ko/build/console-features/storage/directstorage/directstorage-overview.md)
- [Wait](/ko/reference/graphics/d3d12/interfaces/id3d12commandqueue/methods/id3d12commandqueue_wait_public.md)
- [GetDeviceRemovedReason](/ko/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_getdeviceremovedreason_public.md)
- [EventExportCompletionStatus](/ko/services/playfab/api-references/events/data-types/eventexportcompletionstatus.md)
