CefSharp: Download a file in background

Having problems with building or using the CefSharp .NET binding? Ask your CEF-related questions here. Please ask general usage questions on StackOverflow.

Moderator: amaitland

CefSharp: Download a file in background

Postby naveenkn01 » Thu Jul 22, 2021 11:52 pm

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.
naveenkn01
Newbie
 
Posts: 3
Joined: Fri Jul 16, 2021 2:41 am

Re: CefSharp: Download a file in background

Postby ndesktop » Fri Jul 23, 2021 12:03 am

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.
ndesktop
Master
 
Posts: 750
Joined: Thu Dec 03, 2015 10:10 am

Re: CefSharp: Download a file in background

Postby naveenkn01 » Fri Jul 23, 2021 3:00 am

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?
naveenkn01
Newbie
 
Posts: 3
Joined: Fri Jul 16, 2021 2:41 am

Re: CefSharp: Download a file in background

Postby amaitland » Fri Jul 23, 2021 3:45 am

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.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am


Return to CefSharp Forum

Who is online

Users browsing this forum: No registered users and 14 guests