cefsharp/CefSharp · error · Exception
Browser has not yet finished initializing or is being…
Error message
Browser has not yet finished initializing or is being disposed
What it means
Thrown by the example ChromiumWebBrowserWithScreenshotSupport.TakeScreenshot when IsBrowserInitialized is false. Capture works by resizing the off-screen browser and reading the rendered frame in OnPaint; if the browser has not finished initializing (or is being disposed) there is no renderer to produce a frame, so capture is rejected up front.
Solutions
- Wait until IsBrowserInitialized is true (subscribe to IsBrowserInitializedChanged or await initialization) before calling TakeScreenshot.
- Guard with `if (browser.IsBrowserInitialized)` and disable the capture command until initialized.
- Cancel any pending capture when the control starts disposing.
- Ensure the browser has a loaded/committed page before capturing.
Example fix
// before
public MainWindow()
{
browser = new ChromiumWebBrowserWithScreenshotSupport();
var shot = browser.TakeScreenshot(size); // throws: not initialized
}
// after
browser.IsBrowserInitializedChanged += (s, e) =>
{
if (browser.IsBrowserInitialized)
_ = browser.TakeScreenshot(size);
}; Defensive patterns
Strategy: validation
Validate before calling
if (browser.IsBrowserInitialized)
{
_ = browser.TakeScreenshot(size);
} Prevention
- Subscribe to IsBrowserInitializedChanged and capture only after it flips true.
- Disable the screenshot command until initialized.
- Cancel pending captures when disposal begins.
When it happens
Trigger: Calling TakeScreenshot before the browser finished its initial creation; calling during shutdown while the browser is disposing.
Common situations: Wiring the screenshot to a window Loaded event that fires before CEF reports IsBrowserInitialized; capturing immediately after setting Address; capturing during app exit.
Related errors
- IBrowserHost is null
- Browser has already been created. BrowserSettings must be…
- Browser has already been created. RequestContext must be…
- Screenshot already in progress, you must wait for the…
- Unable to take screenshot while browser is loading
AI-assisted analysis of cefsharp/CefSharp@16bc6e0711 (2026-08-13).
Data as JSON: /api/errors/27a470d1c37aad21.
Report an issue: GitHub.
Appendix: source
Thrown at CefSharp.Wpf.Example/Controls/ChromiumWebBrowserWithScreenshotSupport.cs:56
private CancellationTokenRegistration? cancellationTokenRegistration;
public ICommand ScreenshotCommand { get; set; }
public ChromiumWebBrowserWithScreenshotSupport() : base()
{
ScreenshotCommand = new RelayCommand(TakeScreenshot);
}
public Task<InteropBitmap> TakeScreenshot(Size screenshotSize, int? frameRate = 1, int? ignoreFrames = 0, CancellationToken? cancellationToken = null)
{
if (screenshotTaskCompletionSource != null && screenshotTaskCompletionSource.Task.Status == TaskStatus.Running)
{
throw new Exception("Screenshot already in progress, you must wait for the previous screenshot to complete");
}
if (IsBrowserInitialized == false)
{
throw new Exception("Browser has not yet finished initializing or is being disposed");
}
if (IsLoading)
{
throw new Exception("Unable to take screenshot while browser is loading");
}
var browserHost = this.GetBrowserHost();
if (browserHost == null)
{
throw new Exception("IBrowserHost is null");
}
screenshotTaskCompletionSource = new TaskCompletionSource<InteropBitmap>(TaskCreationOptions.RunContinuationsAsynchronously);
if (cancellationToken.HasValue)
{View on GitHub (pinned to 16bc6e0711)