Click or drag to resize

IBrowserDisposeAsync Method

Asynchronously disposes the current browser instance according to the given options.

Namespace:  DotNetBrowser.Browser
Assembly:  DotNetBrowser (in DotNetBrowser.dll) Version: 2.27.7
Syntax
C#
Task<bool> DisposeAsync(
	BrowserDisposeOptions browserDisposeOptions
)

Parameters

browserDisposeOptions
Type: DotNetBrowser.BrowserBrowserDisposeOptions
browser dispose options.

Return Value

Type: TaskBoolean
The task that represents the result of the asynchronous dispose process. True indicates that the browser instance is successfully disposed without any dialogs, false if the dispose process was canceled. This may happen if the BeforeUnloadHandler handler was invoked and the Stay response was sent.
Exceptions
ExceptionCondition
ObjectDisposedExceptionThe IBrowser has already been disposed.
ConnectionClosedExceptionThe connection to the Chromium engine is closed.
Remarks

If the currently loaded web page registers the onbeforeunload JavaScript event and the given options tell the browser to fire the beforeunload event, then this method will not dispose the browser right away.

The BeforeUnloadHandler will be invoked in this case and if the handler tells the browser to stay on the web page, then the browser will not be disposed.

The following example demonstrates how to dispose the browser instance as if a user manually clicking the close button of the tab/window.

browser.DisposeAsync(new BrowserDisposeOptions(){BeforeUnloadEventHandled = true});

If the browser is already disposed, then this method does nothing.

See Also