Skip to content

Commit

Permalink
Handling 'CoreWebView2 members cannot be accessed after the WebView2 …
Browse files Browse the repository at this point in the history
…control is disposed'
  • Loading branch information
Tomasz Gołębiowski committed Feb 6, 2025
1 parent 3f146be commit 4438258
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Cody.UI/Controls/WebviewController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Cody.Core.Common;
using Cody.Core.Logging;
using Microsoft.Web.WebView2.Core;
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using Cody.Core.Logging;
using Cody.Core.Common;

namespace Cody.UI.Controls
{
Expand Down Expand Up @@ -116,6 +116,7 @@ public async Task PostWebMessageAsJson(string message)
{
try
{

// From agent to webview.
await Application.Current.Dispatcher.InvokeAsync(() =>
{
Expand All @@ -127,6 +128,10 @@ await Application.Current.Dispatcher.InvokeAsync(() =>
{
System.Diagnostics.Debug.WriteLine(message, "Agent PostWebMessageAsJson task canceled");
}
catch (AggregateException ex) when (ex.InnerException is InvalidOperationException inex)
{
System.Diagnostics.Debug.WriteLine(inex.Message, "AggregateException in PostWebMessageAsJson");
}
}

private async Task ApplyVsCodeApiScript()
Expand Down

0 comments on commit 4438258

Please sign in to comment.