Skip to content

Commit 1c5d400

Browse files
committed
WinForms/WPF - Dispose of IFrame after calling LoadUrl
1 parent 8ffd29f commit 1c5d400

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CefSharp.WinForms/ChromiumWebBrowser.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,14 @@ private void FreeUnmanagedResources()
510510
/// Loads the specified URL.
511511
/// </summary>
512512
/// <param name="url">The URL to be loaded.</param>
513-
public void Load(String url)
513+
public void Load(string url)
514514
{
515515
if (IsBrowserInitialized)
516516
{
517-
this.GetMainFrame().LoadUrl(url);
517+
using (var frame = this.GetMainFrame())
518+
{
519+
frame.LoadUrl(url);
520+
}
518521
}
519522
else
520523
{

CefSharp.Wpf/ChromiumWebBrowser.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2227,7 +2227,10 @@ public void Load(string url)
22272227
// or before OnApplyTemplate has been called
22282228
if (browser != null)
22292229
{
2230-
browser.MainFrame.LoadUrl(url);
2230+
using (var frame = browser.MainFrame)
2231+
{
2232+
frame.LoadUrl(url);
2233+
}
22312234
}
22322235
}
22332236

0 commit comments

Comments
 (0)