/// <summary>
            /// Retrieves the next frame and copies the texture into the _desktopImageTexture.
            /// </summary>
            /// <param name="frameInformation"></param>
            /// <returns></returns>
            public bool TryRetrieveFrame(out OutduplFrameInfo frameInformation)
            {
                IDXGIResource desktopResource = null;

                try
                {
                    _outputDuplication.AcquireNextFrame(100, out frameInformation, out desktopResource);
                    using var tempTexture = desktopResource.QueryInterface <ID3D11Texture2D>();
                    _d3dDevice.ImmediateContext.CopyResource(_desktopImageTexture, tempTexture);
                    return(true);
                }
                catch (SharpGenException ex)
                {
                    if (ex.ResultCode.Failure && ex.Descriptor.NativeApiCode != "DXGI_ERROR_ACCESS_LOST" && ex.Descriptor.NativeApiCode != "DXGI_ERROR_WAIT_TIMEOUT")
                    {
                        throw new DesktopDuplicationException("Failed to acquire next frame.");
                    }
                }
                finally
                {
                    if (desktopResource != null)
                    {
                        desktopResource.Dispose();
                    }
                }

                frameInformation = new OutduplFrameInfo();
                return(false);
            }
        public override void Update(double deltaTime)
        {
            IDXGIResource    screenResource;
            OutduplFrameInfo frameInfo;

            try
            {
                if (release)
                {
                    duplication.ReleaseFrame();
                    release = false;
                }

                duplication.AcquireNextFrame(500, out frameInfo, out screenResource);

                using (var tempTexture = screenResource.QueryInterface <ID3D11Texture2D>())
                    device.ImmediateContext.CopySubresourceRegion(smallerTexture, 0, 0, 0, 0, tempTexture, 0);

                device.ImmediateContext.GenerateMips(smallerTextureView);
                device.ImmediateContext.CopySubresourceRegion(stagingTexture, 0, 0, 0, 0, smallerTexture, 1);

                var dataBox = device.ImmediateContext.Map(stagingTexture, 0, MapMode.Read, Vortice.Direct3D11.MapFlags.None);

                ProcessDataIntoSKPixmap(dataBox);

                device.ImmediateContext.Unmap(stagingTexture, 0);

                screenResource.Dispose();
                release = true;
                //duplication.ReleaseFrame();
            }
            catch (SharpGen.Runtime.SharpGenException e)
            {
                if (e.ResultCode == Vortice.DXGI.ResultCode.AccessLost)
                {
                    StartDesktopDuplicator(0, 0);
                }
                else if (e.ResultCode == Vortice.DXGI.ResultCode.WaitTimeout)
                {
                    //ignore
                }
                else
                {
                }
                //throw;
            }
        }