Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Winform unload #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CefSharp.MinimalExample.WinForms/BrowserForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ private void HandleToolStripLayout()

private void ExitMenuItemClick(object sender, EventArgs e)
{
// Prevent a race condition where browser.Dispose tears down it's control
// (before all browser cleanup has finished)
// https://github.com/cefsharp/CefSharp/issues/1574
// There are better/more complicated ways to handle this too
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be demonstrating one of those instead?

It's should now be a simple one liner, either of the following should work:

browser.LifeSpanHandler = new CefSharp.WinForms.Handler.LifeSpanHandler();

browser.LifeSpanHandler = CefSharp.WinForms.Handler.LifeSpanHandler
    .Create()
    .Build();

toolStripContainer.ContentPanel.Controls.Remove(browser);
browser.Dispose();
Cef.Shutdown();
Close();
Expand Down