diff --git a/CefSharp.OffScreen.Example/Program.cs b/CefSharp.OffScreen.Example/Program.cs
index ae6fd9531..95ed2425e 100644
--- a/CefSharp.OffScreen.Example/Program.cs
+++ b/CefSharp.OffScreen.Example/Program.cs
@@ -29,22 +29,24 @@ namespace CefSharp.OffScreen.Example
CefExample.Init();
// Create the offscreen Chromium browser.
- browser = new ChromiumWebBrowser(testUrl);
-
- // An event that is fired when the first page is finished loading.
- // This returns to us from another thread.
- if (captureFirstRenderedImage)
+ using (browser = new ChromiumWebBrowser(testUrl))
{
- browser.ResourceHandler.RegisterHandler(testUrl, ResourceHandler.FromString("
CefSharp OffScreen
"));
- browser.ScreenshotAsync().ContinueWith(DisplayBitmap);
- }
- else
- {
- browser.FrameLoadEnd += BrowserFrameLoadEnd;
- }
- // We have to wait for something, otherwise the process will exit too soon.
- Console.ReadKey();
+ // An event that is fired when the first page is finished loading.
+ // This returns to us from another thread.
+ if (captureFirstRenderedImage)
+ {
+ browser.ResourceHandler.RegisterHandler(testUrl, ResourceHandler.FromString("CefSharp OffScreen
"));
+ browser.ScreenshotAsync().ContinueWith(DisplayBitmap);
+ }
+ else
+ {
+ browser.FrameLoadEnd += BrowserFrameLoadEnd;
+ }
+
+ // We have to wait for something, otherwise the process will exit too soon.
+ Console.ReadKey();
+ }
// Clean up Chromium objects. You need to call this in your application otherwise
// you will get a crash when closing.