The Hide method changes the visibility state of the browser
control. When the browser was created as a top-level window using
Create, this method internally calls the standard ShowWindow
API to hide the entire browser window. The window will be restored with
the Show method.
When the browser is embedded in an existing host window using
Attach, the method does not change the visibility of the parent
window. Instead, it sends an internal message to the control to hide
the child window which contains the WebView2 browser. This enables
the host application to change the visibility of the browser control
independently of other controls in the same window.
This method does not destroy the browser instance or unload its
current content. Hiding the browser simply makes it invisible; it can
be shown again without requiring a reload of the current document.
The current visibility state can be queried using the IsVisible
method.
Hiding the browser window can also provide performance benefits
in scenarios where the application does not need to display the page
contents for a period of time. While background tasks such as script
execution and network activity continue as normal, the browser will not
spend resources on rendering or updating the visual output when the
control is not visible. This can reduce CPU and GPU usage, particularly
when the page is dynamic or graphically intensive.