Skip to content

Commit 71a190d

Browse files
committed
OffScreen Example - Demo Cef.WaitForBrowsersToClose();
Issue #3047
1 parent 6b440a8 commit 71a190d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CefSharp.OffScreen.Example/Program.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public static int Main(string[] args)
2222
Console.WriteLine("You may see a lot of Chromium debugging output, please wait...");
2323
Console.WriteLine();
2424

25+
Cef.EnableWaitForBrowsersToClose();
26+
2527
// You need to replace this with your own call to Cef.Initialize();
2628
CefExample.Init(new CefSettings(), browserProcessHandler: new BrowserProcessHandler());
2729

@@ -34,6 +36,11 @@ public static int Main(string[] args)
3436
// We have to wait for something, otherwise the process will exit too soon.
3537
Console.ReadKey();
3638

39+
//Wait until the browser has finished closing (which by default happens on a different thread).
40+
//Cef.EnableWaitForBrowsersToClose(); must be called before Cef.Initialize to enable this feature
41+
//See https://github.com/cefsharp/CefSharp/issues/3047 for details
42+
Cef.WaitForBrowsersToClose();
43+
3744
// Clean up Chromium objects. You need to call this in your application otherwise
3845
// you will get a crash when closing.
3946
Cef.Shutdown();

0 commit comments

Comments
 (0)