From 3d8165f207c773a6609275de3e8a1e9b64f545ce Mon Sep 17 00:00:00 2001 From: amaitland Date: Wed, 16 Sep 2015 08:41:42 +1000 Subject: [PATCH] Update OffScreen example to always invalida the view before capturing the second image (getting the latest image in the process, not the last stored one) --- CefSharp.OffScreen.Example/Program.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/CefSharp.OffScreen.Example/Program.cs b/CefSharp.OffScreen.Example/Program.cs index dc7df6cb9..47835fb98 100644 --- a/CefSharp.OffScreen.Example/Program.cs +++ b/CefSharp.OffScreen.Example/Program.cs @@ -66,13 +66,24 @@ namespace CefSharp.OffScreen.Example // For Google.com pre-pupulate the search text box await browser.EvaluateScriptAsync("document.getElementById('lst-ib').value = 'CefSharp Was Here!'"); - // Wait for the screenshot to be taken. + // Wait for the screenshot to be taken, + // if one exists ignore it, wait for a new one to make sure we have the most up to date await browser.ScreenshotAsync(true).ContinueWith(DisplayBitmap); await LoadPageAsync(browser, "http://github.com"); + + //Gets a wrapper around the underlying CefBrowser instance + var cefBrowser = browser.GetBrowser(); + // Gets a warpper around the CefBrowserHost instance + // You can perform a lot of low level browser operations using this interface + var cefHost = cefBrowser.GetHost(); + + //You can call Invalidate to redraw/refresh the image + cefHost.Invalidate(PaintElementType.View); + // Wait for the screenshot to be taken. - await browser.ScreenshotAsync().ContinueWith(DisplayBitmap); + await browser.ScreenshotAsync(true).ContinueWith(DisplayBitmap); } }