CWebView::SetTimeout Method  
 
INT SetTimeout(
  INT nTimeout  
);

The SetTimeout method sets the number of seconds the browser will wait for a response from the server.

Parameters

nTimeout
The number of seconds to wait for the navigation to complete.

Return Value

If the method succeeds, the return value is zero. If the function fails, the return value is WEBVIEW_ERROR. To get extended error information, call GetLastError.

Remarks

The SetTimeout method specifies the maximum number of seconds that the library should wait for a navigation request to complete. This timeout begins when navigation starts and ends when the navigation completes or fails.

If the timeout period is set to zero, the library does not enforce its own timer and instead relies on the default timeouts implemented by the WebView2 engine. These built-in timeouts automatically handle conditions such as slow DNS resolution, stalled connections, or unreachable servers, and generally behave in the same way as the Microsoft Edge browser.

If a non-zero timeout period is specified, the control will cancel the navigation if the internal timer exceeds that value and the page has not finished loading. When this occurs, the navigation is stopped and a timeout error is reported through the standard navigation event notifications. This allows applications to fail fast in cases where a site is not responding, rather than waiting for the browser's adaptive timeouts to expire.

Note that specifying a very large timeout value will not force the browser to wait indefinitely. The WebView2 engine may still apply its own internal maximums and terminate the navigation earlier if it decides the request cannot succeed. Applications should select timeout values that balance responsiveness and reliability.

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