Table of Contents

Class WebViewHost

Namespace
VpnHood.AppUi.Hosting.WebView
Assembly
VpnHood.AppUi.Hosting.WebView.dll

Provides the platform-neutral control of a web view that hosts the app's web UI: it starts the page host it is handed, works out the launch address, drives the loading and error states, and loads the UI again after the web view reports a failure.

public sealed class WebViewHost : IDisposable
Inheritance
WebViewHost
Implements
Inherited Members

Remarks

Only the native web view's mechanics are the platform's, in its IWebView. A platform host makes one per web view, calls Start() when its UI is created, OnResume() from its resume hook, and Dispose() when it is torn down. A failed load is tried again: the page host is asked for its address again, which a server the platform owns checks, and after a second's wait the page loads again; another failure starts another round.

Constructors

WebViewHost(IWebView, IWebViewPageHost, WebViewHostOptions?)

Initializes a new instance of the WebViewHost class.

public WebViewHost(IWebView view, IWebViewPageHost pageHost, WebViewHostOptions? options = null)

Parameters

view IWebView

The platform's web view.

pageHost IWebViewPageHost

The server the page comes from.

options WebViewHostOptions

The options, or null for the defaults.

Exceptions

ArgumentNullException

view or pageHost is null.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Remarks

It stops following the web view's and the page host's events; a second call does nothing.

OnResume()

Tells the app's UI context the app is in front again; a platform host calls it from its resume hook.

public void OnResume()

Start()

Starts the page host off the UI thread, then makes the web view and loads the UI on the UI thread; where the page host fails to start, the failure goes to the web view's ShowError(string).

public void Start()