CWebView::WaitUntilClosed Method  
 
BOOL WaitUntilClosed(
  DWORD dwMilliseconds  
);

The WaitUntilClosed method waits until the host window is closed or destroyed.

Parameters

dwMilliseconds
The number of milliseconds to wait for the browser window to close. If this amount of time elapses, the method returns. If this value is zero, the method will not enter a wait state and returns immediately. This value may be INFINITE in which case the function will not return until the window is closed.

Return Value

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.

Remarks

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.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtmv12.lib

See Also