/// <inheritdoc />
        /// <summary>
        ///   Acquires a single frame
        /// </summary>
        /// <inheritdoc />
        /// <summary>
        ///   Acquires a single frame from this provider
        /// </summary>
        public override void AcquireFrame()
        {
            for (int i = 0; i < this.sources.Length; i++)
            {
                DxgiCaptureSource source = this.sources[i];

                try {
                    OutputDuplicateFrameInformation info;
                    Resource desktopResource = null;

                    do
                    {
                        // release previous frame if last capture attempt failed
                        if (desktopResource != null)
                        {
                            desktopResource.Dispose();
                            source.Duplication.ReleaseFrame();
                        }

                        // try to capture a frame
                        source.Duplication.AcquireNextFrame(DuplicationFrameTimeout,
                                                            out info,
                                                            out desktopResource);
                    } while (info.TotalMetadataBufferSize == 0);

                    this.lastPresentTime = info.LastPresentTime;

                    using (var srcResource = desktopResource.QueryInterface <SharpDX.Direct3D11.Resource>())
                        using (var destResource = source.Texture.QueryInterface <SharpDX.Direct3D11.Resource>()) {
                            // copy the entire screen region to the target texture
                            source.Context.CopySubresourceRegion(
                                srcResource,
                                0,
                                source.Subregion,
                                destResource,
                                0);
                        }

                    // release resources
                    desktopResource.Dispose();
                    source.Duplication.ReleaseFrame();
                } catch (SharpDXException exception) when(exception.ResultCode == ResultCode.AccessLost ||
                                                          exception.ResultCode == ResultCode.DeviceHung ||
                                                          exception.ResultCode == ResultCode.DeviceRemoved)
                {
                    // device has been lost - we can't ignore this and should try to reinitialize the D3D11 device until it's
                    // available again (...)
                    // we'll be receiving black/unsynced frames beyond this point - it is OK until we restore the device
                    while (true)
                    {
                        try {
                            this.sources[i] = DxgiCaptureSource.Recreate(this.virtualRect);
                            break; // successfully restored capture source
                        } catch (SharpDXException) {
                            /* could not restore the capture source - keep trying */
                        }
                    }
                }
            }
        }