> ## 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.

# PIXEndCapture

> PIXEndCapture

# PIXEndCapture

Stops a programmatically controlled capture that was started with `PIXBeginCapture`.

## Syntax

```cpp theme={null}
HRESULT PIXEndCapture(  
         BOOL discard  
)  
```

### Parameters

*discard*   \
Type: BOOL

Indicates whether the capture should be discarded:

* If *discard* is TRUE, the captured data is discarded, and the capture will not be displayed in PIX.
* If *discard* is FALSE, the captured data is saved, and PIX will display the resulting capture.

The *discard* parameter is useful to throw away captures that didn't meet the criteria you were looking for. For example, you can use `PIXBeginCapture` and `PIXEndCapture` to attempt to capture calls to a function that fall within a predefined time range. You may wish to only display captures for calls to a function that fall within that range.

### Return value

Type: HRESULT

Indicates whether the capture complete successfully. S\_OK is returned on success. The operation is asynchronous and it will return E\_PENDING until the capture is fully stopped. The title should not exit or start a new capture while the result is E\_PENDING.

## Remarks

Use [PIXBeginCapture](/reference/tools/pix3/functions/pixbegincapture) to begin a PIX capture.\
For more information about requirements for starting a PIX capture, see the Remarks section of [PIXBeginCapture](/reference/tools/pix3/functions/pixbegincapture).

The following C++ sample demonstrates how to begin and end a PIX capture.

```cpp theme={null}
//
//  timing capture
//
PIXCaptureParameters captureParams = {};

captureParams.TimingCaptureParameters.CaptureGpuTiming = TRUE;
captureParams.TimingCaptureParameters.CaptureCallstacks = TRUE;
captureParams.TimingCaptureParameters.CaptureCpuSamples = TRUE;
captureParams.TimingCaptureParameters.CpuSamplesPerSecond = 4000;

captureParams.TimingCaptureParameters.CaptureStorage = PIXCaptureParameters::Memory;
captureParams.TimingCaptureParameters.FileName = wstrFilename;
captureParams.TimingCaptureParameters.MaximumToolingMemorySizeMb = 4096;

XSF_ERROR_IF_FAILED(PIXBeginCapture(PIX_CAPTURE_TIMING, &captureParams));

while (PIXEndCapture(FALSE) == E_PENDING)
{
    // Keep running
}

```

## Requirements

**Header:** pix3.h

**Library:** pixevt.lib

**Supported platforms:** XBOX One family consoles and XBOX Series consoles

## See also

[PIXBeginCapture](/reference/tools/pix3/functions/pixbegincapture)\
[PIX3](/reference/tools/pix3/pix3_members)\
[PIX (NDA topic)](/tools/tools-console/pix/pix)


## Related topics

- [PIX3](/reference/tools/pix3/pix3_members.md)
- [XtfCaptureOutputEnd](/reference/tools/xtf/xtfapi/functions/xtfcaptureoutputend-xtfapi-xbox-windows-m.md)
- [XtfCaptureOutputBegin](/reference/tools/xtf/xtfapi/functions/xtfcaptureoutputbegin-xtfapi-xbox-windows-m.md)
- [XAppCaptureMetadataStopAllStates](/reference/system/xappcapture/functions/xappcapturemetadatastopallstates.md)
- [PIXEndEvent](/reference/tools/pix3/functions/pixendevent_2.md)
