MCPcopy Create free account
hub / github.com/MicrosoftEdge/WebView2Samples / Suspend

Method Suspend

SampleApps/WebView2APISample/ViewComponent.cpp:456–477  ·  view source on GitHub ↗

[Suspend]

Source from the content-addressed store, hash-verified

454
455//! [Suspend]
456void ViewComponent::Suspend()
457{
458 wil::com_ptr<ICoreWebView2_3> webView;
459 webView = m_webView.try_query<ICoreWebView2_3>();
460 CHECK_FEATURE_RETURN_EMPTY(webView);
461 HRESULT hr = webView->TrySuspend(
462 Callback<ICoreWebView2TrySuspendCompletedHandler>(
463 [this](HRESULT errorCode, BOOL isSuccessful) -> HRESULT {
464 if ((errorCode != S_OK) || !isSuccessful)
465 {
466 std::wstringstream formattedMessage;
467 formattedMessage << "TrySuspend result (0x" << std::hex << errorCode
468 << ") " << (isSuccessful ? "succeeded" : "failed");
469 m_appWindow->AsyncMessageBox(
470 std::move(formattedMessage.str()), L"TrySuspend result");
471 }
472 return S_OK;
473 })
474 .Get());
475 if (FAILED(hr))
476 ShowFailure(hr, L"Call to TryFreeze failed");
477}
478//! [Suspend]
479
480//! [MemoryUsageTargetLevel]

Callers

nothing calls this directly

Calls 2

AsyncMessageBoxMethod · 0.80
ShowFailureFunction · 0.70

Tested by

no test coverage detected