protected virtual void Dispose(bool disposing) { // Don't reference handlers any longer: ResourceHandlerFactory = null; JsDialogHandler = null; DialogHandler = null; DownloadHandler = null; KeyboardHandler = null; LifeSpanHandler = null; MenuHandler = null; FocusHandler = null; RequestHandler = null; DragHandler = null; GeolocationHandler = null; // Don't reference event listeners any longer: LoadError = null; FrameLoadStart = null; FrameLoadEnd = null; ConsoleMessage = null; BrowserInitialized = null; StatusMessage = null; NavStateChanged = null; AddressChanged = null; IsLoadingChanged = null; Cef.RemoveDisposable(this); if (disposing) { IsBrowserInitialized = false; if (bitmap != null) { bitmap.Dispose(); bitmap = null; } if (BrowserSettings != null) { BrowserSettings.Dispose(); BrowserSettings = null; } if (managedCefBrowserAdapter != null) { if (!managedCefBrowserAdapter.IsDisposed) { managedCefBrowserAdapter.Dispose(); } managedCefBrowserAdapter = null; } } }
protected override void Dispose(bool disposing) { // Don't utilize any of the handlers anymore: DialogHandler = null; JsDialogHandler = null; KeyboardHandler = null; RequestHandler = null; DownloadHandler = null; LifeSpanHandler = null; MenuHandler = null; DragHandler = null; GeolocationHandler = null; FocusHandler = null; ResourceHandlerFactory = null; Cef.RemoveDisposable(this); if (disposing) { IsBrowserInitialized = false; if (BrowserSettings != null) { BrowserSettings.Dispose(); BrowserSettings = null; } if (parentFormMessageInterceptor != null) { parentFormMessageInterceptor.Dispose(); parentFormMessageInterceptor = null; } if (managedCefBrowserAdapter != null) { managedCefBrowserAdapter.Dispose(); managedCefBrowserAdapter = null; } // Don't maintain a reference to event listeners anylonger: LoadError = null; FrameLoadStart = null; FrameLoadEnd = null; NavStateChanged = null; ConsoleMessage = null; StatusMessage = null; AddressChanged = null; TitleChanged = null; IsBrowserInitializedChanged = null; IsLoadingChanged = null; } base.Dispose(disposing); }
private void FreeUnmanagedResources() { browser = null; if (BrowserSettings != null) { BrowserSettings.Dispose(); BrowserSettings = null; } if (managedCefBrowserAdapter != null) { managedCefBrowserAdapter.Dispose(); managedCefBrowserAdapter = null; } }
public void BeginRender() { EndRender(); var cefWindowInfo = CreateWindowInfo(); _isWindowless = cefWindowInfo.WindowlessRenderingEnabled; var cefBrowserSettings = new BrowserSettings(); cefBrowserSettings.WindowlessFrameRate = _target.MaxFrameRate; _browser.CreateBrowser(cefWindowInfo, cefBrowserSettings); cefBrowserSettings.Dispose(); cefWindowInfo.Dispose(); }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { // Don't reference event listeners any longer: LoadError = null; FrameLoadStart = null; FrameLoadEnd = null; ConsoleMessage = null; BrowserInitialized = null; StatusMessage = null; LoadingStateChanged = null; AddressChanged = null; Cef.RemoveDisposable(this); if (disposing) { browser = null; IsBrowserInitialized = false; if (Bitmap != null) { Bitmap.Dispose(); Bitmap = null; } if (BrowserSettings != null) { BrowserSettings.Dispose(); BrowserSettings = null; } if (managedCefBrowserAdapter != null) { if (!managedCefBrowserAdapter.IsDisposed) { managedCefBrowserAdapter.Dispose(); } managedCefBrowserAdapter = null; } } // Release reference to handlers, make sure this is done after we dispose managedCefBrowserAdapter // otherwise the ILifeSpanHandler.DoClose will not be invoked. (More important in the WinForms version, // we do it here for consistency) this.SetHandlersToNull(); }
/// <summary> /// Releases the unmanaged resources used by the <see cref="T:System.Windows.Forms.Control" /> and its child controls and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { Cef.RemoveDisposable(this); if (disposing) { browser = null; IsBrowserInitialized = false; if (BrowserSettings != null) { BrowserSettings.Dispose(); BrowserSettings = null; } if (parentFormMessageInterceptor != null) { parentFormMessageInterceptor.Dispose(); parentFormMessageInterceptor = null; } if (managedCefBrowserAdapter != null) { managedCefBrowserAdapter.Dispose(); managedCefBrowserAdapter = null; } // Don't maintain a reference to event listeners anylonger: LoadError = null; FrameLoadStart = null; FrameLoadEnd = null; LoadingStateChanged = null; ConsoleMessage = null; StatusMessage = null; AddressChanged = null; TitleChanged = null; IsBrowserInitializedChanged = null; } // Release reference to handlers, make sure this is done after we dispose managedCefBrowserAdapter // otherwise the ILifeSpanHandler.DoClose will not be invoked. this.SetHandlersToNull(); base.Dispose(disposing); }
public void BeginRender() { EndRender(); var cefWindowInfo = new WindowInfo(); cefWindowInfo.SetAsWindowless(IntPtr.Zero); cefWindowInfo.Width = _target.Width; cefWindowInfo.Height = _target.Height; var cefBrowserSettings = new BrowserSettings(); cefBrowserSettings.WindowlessFrameRate = _target.MaxFrameRate; _browser.CreateBrowser(cefWindowInfo, cefBrowserSettings); cefBrowserSettings.Dispose(); cefWindowInfo.Dispose(); }
protected virtual void Dispose(bool disposing) { // Don't reference handlers any longer: this.SetHandlersToNull(); // Don't reference event listeners any longer: LoadError = null; FrameLoadStart = null; FrameLoadEnd = null; ConsoleMessage = null; BrowserInitialized = null; StatusMessage = null; LoadingStateChanged = null; AddressChanged = null; Cef.RemoveDisposable(this); if (disposing) { browser = null; IsBrowserInitialized = false; if (bitmap != null) { bitmap.Dispose(); bitmap = null; } if (BrowserSettings != null) { BrowserSettings.Dispose(); BrowserSettings = null; } if (managedCefBrowserAdapter != null) { if (!managedCefBrowserAdapter.IsDisposed) { managedCefBrowserAdapter.Dispose(); } managedCefBrowserAdapter = null; } } }
/// <summary> /// Releases the unmanaged resources used by the <see cref="T:System.Windows.Forms.Control" /> and its child controls and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { // Don't utilize any of the handlers anymore: this.SetHandlersToNull(); Cef.RemoveDisposable(this); if (disposing) { browser = null; IsBrowserInitialized = false; if (BrowserSettings != null) { BrowserSettings.Dispose(); BrowserSettings = null; } if (parentFormMessageInterceptor != null) { parentFormMessageInterceptor.Dispose(); parentFormMessageInterceptor = null; } if (managedCefBrowserAdapter != null) { managedCefBrowserAdapter.Dispose(); managedCefBrowserAdapter = null; } // Don't maintain a reference to event listeners anylonger: LoadError = null; FrameLoadStart = null; FrameLoadEnd = null; LoadingStateChanged = null; ConsoleMessage = null; StatusMessage = null; AddressChanged = null; TitleChanged = null; IsBrowserInitializedChanged = null; } base.Dispose(disposing); }
private void FreeUnmanagedResources() { // Repeated if missed Cef.Shutdown(); _browser = null; if (BrowserSettings != null) { BrowserSettings.Dispose(); BrowserSettings = null; } if (_managedCefBrowserAdapter != null) { _managedCefBrowserAdapter.Dispose(); _managedCefBrowserAdapter = null; } }
protected override void Dispose(bool disposing) { FocusHandler = null; ResourceHandler = null; BrowserSettings.Dispose(); BrowserSettings = null; Cef.RemoveDisposable(this); if (disposing) { if (managedCefBrowserAdapter != null) { managedCefBrowserAdapter.Dispose(); managedCefBrowserAdapter = null; } } base.Dispose(disposing); }
public void BeginRender(int width, int height, string url, int maxFrameRate = 30) { EndRender(); var cefWindowInfo = new WindowInfo(); cefWindowInfo.SetAsWindowless(IntPtr.Zero); cefWindowInfo.Width = width; cefWindowInfo.Height = height; var cefBrowserSettings = new BrowserSettings(); cefBrowserSettings.WindowlessFrameRate = maxFrameRate; _browser.CreateBrowser(cefWindowInfo, cefBrowserSettings); cefBrowserSettings.Dispose(); cefWindowInfo.Dispose(); urlToLoad = url; }
private void FreeUnmanagedResources() { browser = null; if (parentFormMessageInterceptor != null) { parentFormMessageInterceptor.Dispose(); parentFormMessageInterceptor = null; } if (BrowserSettings != null) { BrowserSettings.Dispose(); BrowserSettings = null; } if (managedCefBrowserAdapter != null) { managedCefBrowserAdapter.Dispose(); managedCefBrowserAdapter = null; } }
protected virtual void Dispose(bool isdisposing) { PresentationSource.RemoveSourceChangedHandler(this, PresentationSourceChangedHandler); BrowserSettings.Dispose(); BrowserSettings = null; ResourceHandler = null; Loaded -= OnLoaded; GotKeyboardFocus -= OnGotKeyboardFocus; LostKeyboardFocus -= OnLostKeyboardFocus; // Drag Drop events DragEnter -= OnDragEnter; DragOver -= OnDragOver; DragLeave -= OnDragLeave; Drop -= OnDrop; IsVisibleChanged -= OnIsVisibleChanged; Cef.RemoveDisposable(this); foreach (var disposable in disposables) { disposable.Dispose(); } disposables.Clear(); UiThreadRunAsync(() => WebBrowser = null); managedCefBrowserAdapter = null; ConsoleMessage = null; FrameLoadStart = null; FrameLoadEnd = null; LoadError = null; }
protected virtual void Dispose(bool isdisposing) { // No longer reference event listeners: ConsoleMessage = null; FrameLoadStart = null; FrameLoadEnd = null; LoadError = null; NavStateChanged = null; // No longer reference handlers: ResourceHandlerFactory = null; DialogHandler = null; JsDialogHandler = null; KeyboardHandler = null; RequestHandler = null; DownloadHandler = null; LifeSpanHandler = null; MenuHandler = null; FocusHandler = null; DragHandler = null; GeolocationHandler = null; Rendering = null; if (isdisposing) { if (BrowserSettings != null) { BrowserSettings.Dispose(); BrowserSettings = null; } PresentationSource.RemoveSourceChangedHandler(this, PresentationSourceChangedHandler); // Release internal event listeners: Loaded -= OnLoaded; GotKeyboardFocus -= OnGotKeyboardFocus; LostKeyboardFocus -= OnLostKeyboardFocus; // Release internal event listeners for Drag Drop events: DragEnter -= OnDragEnter; DragOver -= OnDragOver; DragLeave -= OnDragLeave; Drop -= OnDrop; IsVisibleChanged -= OnIsVisibleChanged; if (tooltipTimer != null) { tooltipTimer.Tick -= OnTooltipTimerTick; } if (CleanupElement != null) { CleanupElement.Unloaded -= OnCleanupElementUnloaded; } foreach (var disposable in disposables) { disposable.Dispose(); } disposables.Clear(); UiThreadRunAsync(() => WebBrowser = null); } Cef.RemoveDisposable(this); RemoveSourceHook(); managedCefBrowserAdapter = null; }
public void Dispose() { if (isDisposing) { return; } isDisposing = true; GC.SuppressFinalize(this); var disposed = false; void InternalDispose() { if (disposed) { return; // bail-out } disposed = true; AppDomain.CurrentDomain.AssemblyLoad -= OnAssemblyLoaded; DisposableWebViews.Remove(this); cancellationTokenSource.Cancel(); WebViewInitialized = null; BeforeNavigate = null; BeforeResourceLoad = null; Navigated = null; LoadFailed = null; DownloadProgressChanged = null; DownloadCompleted = null; DownloadCancelled = null; JavascriptContextCreated = null; TitleChanged = null; UnhandledAsyncException = null; RenderProcessCrashed = null; JavascriptContextReleased = null; jsExecutor.Dispose(); settings.Dispose(); chromium.Dispose(); cancellationTokenSource.Dispose(); Disposed?.Invoke(); } // avoid dead-lock, wait for all pending calls to finish JavascriptCallFinished += () => { if (javascriptPendingCalls == 0) { Dispatcher.BeginInvoke((Action)InternalDispose); } }; if (javascriptPendingCalls > 0) { // JavascriptCallFinished event will trigger InternalDispose, // this check must come after registering event to avoid losing the event call return; } InternalDispose(); }
protected virtual void Dispose(bool isdisposing) { //Check if alreadty disposed if (Interlocked.Increment(ref disposeCount) == 1) { // No longer reference event listeners: ConsoleMessage = null; FrameLoadStart = null; FrameLoadEnd = null; LoadError = null; LoadingStateChanged = null; Rendering = null; // No longer reference handlers: this.SetHandlersToNull(); if (isdisposing) { if (BrowserSettings != null) { BrowserSettings.Dispose(); BrowserSettings = null; } PresentationSource.RemoveSourceChangedHandler(this, PresentationSourceChangedHandler); // Release internal event listeners: Loaded -= OnLoaded; GotKeyboardFocus -= OnGotKeyboardFocus; LostKeyboardFocus -= OnLostKeyboardFocus; // Release internal event listeners for Drag Drop events: DragEnter -= OnDragEnter; DragOver -= OnDragOver; DragLeave -= OnDragLeave; Drop -= OnDrop; IsVisibleChanged -= OnIsVisibleChanged; if (tooltipTimer != null) { tooltipTimer.Tick -= OnTooltipTimerTick; } if (CleanupElement != null) { CleanupElement.Unloaded -= OnCleanupElementUnloaded; } if (managedCefBrowserAdapter != null) { managedCefBrowserAdapter.Dispose(); managedCefBrowserAdapter = null; } foreach (var disposable in disposables) { disposable.Dispose(); } disposables.Clear(); UiThreadRunAsync(() => WebBrowser = null); } Cef.RemoveDisposable(this); RemoveSourceHook(); } }