Page 1 of 1

CefSharp: Download a file in background

PostPosted: Thu Jul 22, 2021 11:52 pm
by naveenkn01
Hi,

I have added Cefsharp browser in UserControl for my WPF application. Implemented IDownloadHandler for downloading a file.

Suppose I download a large file assume 4gb zip file, I select a download location on the dialog and download starts in background.

I will close the browser window immedietly assuming download will happen in background, but download will not happen in the background.
In current architecture as soon as browser window is closed, browser window objects gets disposed.

How do we download a file even after closing the browser window.
Is this achievable? Basically we do not want user to wait while downloading a large file by keeping browser window open.

Re: CefSharp: Download a file in background

PostPosted: Fri Jul 23, 2021 12:03 am
by ndesktop
I think you have two options:
1. make the browser window invisible and wait until the download is finished to dispose the browser
2. intercept the download at the request level, cancel it and do the download yourself.

Re: CefSharp: Download a file in background

PostPosted: Fri Jul 23, 2021 3:00 am
by naveenkn01
Option 1 not possible as per current archtecture, objects will be disposed as soon as window is closed.

Before closing the window, is it possible to transfer\assign dowload process to another process\browser?

Re: CefSharp: Download a file in background

PostPosted: Fri Jul 23, 2021 3:45 am
by amaitland
It's not possible to transfer the download to a different browser.

Changing your current architecture likely isn't that hard, before window closes check for pending downloads, hide the window, close when download complete.

Alternatively you can reparent the browser to a hidden window.

If downloads don't require authentication/post data then just use the built in .Net functionality to download the file.