We have a need where in we need to query image server for image and display it on CEF web browser control within Windows form.
public partial class CustomerWindow : Form
{
private string image_url;
private ChromiumWebBrowser _browser;
private bool _browserInitialised = false;
public CustomerWindow()
{
browser.IsBrowserInitializedChanged += OnIsBrowserInitializedChanged;
}
// calls to server for validating user credentials and get cookie
public LoadData()
{
if(_browserInitialised)
{
browser.Load(_imsContextualImageUrl);
}
}
public void OnIsBrowserInitializedChanged(object sender, EventArgs e)
{
var chromeWebBrowser = (ChromiumWebBrowser)sender;
if (!chromeWebBrowser.IsBrowserInitialized) return;
chromeWebBrowser.Load(_imsContextualImageUrl);
_browserInitialised = true;
}
}
We are creating CEF browser only once per application and disposing it at the close event of form.
Code is working and displaying image for the urls which has data, when there is no data , we need to clear the previous image displayed on CEF browser and shown empty CEF browser.
Is there any solution other than disposing CEF browser and recreating it for every launch request?