If the browser window has been closed, the return value is non-zero.
If the timeout period has been exceeded or the method fails, the return
value is zero. To get extended error information, call
GetLastError.
The WaitUntilClosed method blocks the calling thread until
the browser window created by Create has been closed or destroyed,
or until the specified timeout interval has elapsed. Internally, this
method waits on the thread handle associated with the WebView2 instance
using the WaitForSingleObject function.
This method can only be used with browser windows that were created
by this class using the Create method. It is not valid to call
this method with an instance that was attached to a window using
Attach. Attempting to do so will cause the method to fail.
Unlike WaitForEvent, this method does not process any
Windows messages while it is waiting. As a result, it should not be used
by applications that have a message loop, such as GUI programs that create
windows with menus, controls, or dialog boxes. Because messages are not
dispatched, the application's user interface may become unresponsive if
this method is called from the primary UI thread.
This method is intended primarily for use in console applications
or background worker threads, where it may be necessary to determine
when the browser window has been closed by the user. GUI applications
should use the WEBVIEW_EVENT_WINDOW_DETACHED event
notification instead of calling this method.