D3D12HelloBundles.HelloBundles.WaitForPreviousFrame C# (CSharp) Method

WaitForPreviousFrame() private method

Wait the previous command list to finish executing.
private WaitForPreviousFrame ( ) : void
return void
        private void WaitForPreviousFrame()
        {
            // WAITING FOR THE FRAME TO COMPLETE BEFORE CONTINUING IS NOT BEST PRACTICE.
            // This is code implemented as such for simplicity.

            int currentFence = fenceValue;
            commandQueue.Signal(fence, currentFence);
            fenceValue++;

            // Wait until the previous frame is finished.
            if (fence.CompletedValue < currentFence)
            {
                fence.SetEventOnCompletion(currentFence, fenceEvent.SafeWaitHandle.DangerousGetHandle());
                fenceEvent.WaitOne();
            }

            frameIndex = swapChain.CurrentBackBufferIndex;
        }