MicrosoftEdge / MicrosoftEdge/WebView2Feedback
Error "The group or resource is not in the correct state to perform the requested operation" when doing WebView2.TrySuspendAsync
@champnic is already working on this.
Since Apr 29, 2022.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
I basically need to pause a video when the WebView2 control loses its visibility.
What I did was this:
/*********************************************************************/
private async void SuspendWebView2(WebView2 webView2 )
{
bool bRes = await webView2.CoreWebView2.TrySuspendAsync();
}
/*********************************************************************/
private void WebCtrl_VisibleChanged(object sender, EventArgs e)
{
WebView2 webView2 = (WebView2)sender;
if (webView2.Visible == false && webView2.CoreWebView2.IsDocumentPlayingAudio )
{
webView2.CoreWebView2.IsMuted = true;
SuspendWebView2(webView2);
}
else if (webView2.Visible == true && webView2.CoreWebView2.IsDocumentPlayingAudio )
{
webView2.CoreWebView2.IsMuted = false;
webView2.CoreWebView2.Resume();
}
}
But I get:
System.InvalidOperationException: CoreWebView2 members cannot be accessed after the WebView2 control is disposed. ---> System.Runtime.InteropServices.COMException: The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F)
I tried a lot of things including hiding or showing the control (sometimes it works but it is not the same all the time), setting a timer and doing it few seconds after and so on....
Version
SDK: 1.0.1185.39
Runtime: 100.0.1185.50
Framework: WinForms
OS: Win10
Repro Steps
Screenshots
Additional context
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.