Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzart committed Nov 30, 2023
1 parent f909d62 commit 009732f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
5 changes: 1 addition & 4 deletions src/DynamoUtilities/CLIWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,7 @@ protected virtual string GetData(int timeoutms)
}
});

var completedTask = Task.WhenAny(readStdOutTask, Task.Delay(TimeSpan.FromMilliseconds(timeoutms))).Result;
//if the completed task was our read std out task, then return the data
//else we timed out, so return an empty string.
return completedTask == readStdOutTask ? readStdOutTask.Result : string.Empty;
return readStdOutTask.Wait(timeoutms) ? readStdOutTask.Result : string.Empty;
}

protected void RaiseMessageLogged(string message)
Expand Down
21 changes: 12 additions & 9 deletions src/LibraryViewExtensionWebView2/LibraryViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,19 @@ async void InitializeAsync()
};
}

isInitialized = browser.EnsureCoreWebView2Async().ContinueWith((_) =>
if (isInitialized == null)
{
if (isDisposing) return;

this.browser.CoreWebView2.WebMessageReceived += CoreWebView2_WebMessageReceived;
twoWayScriptingObject = new ScriptingObject(this);
//register the interop object into the browser.
this.browser.CoreWebView2.AddHostObjectToScript("bridgeTwoWay", twoWayScriptingObject);
browser.CoreWebView2.Settings.IsZoomControlEnabled = true;
}, TaskScheduler.FromCurrentSynchronizationContext());
isInitialized = browser.EnsureCoreWebView2Async().ContinueWith((_) =>
{
if (isDisposing) return;

this.browser.CoreWebView2.WebMessageReceived += CoreWebView2_WebMessageReceived;
twoWayScriptingObject = new ScriptingObject(this);
//register the interop object into the browser.
this.browser.CoreWebView2.AddHostObjectToScript("bridgeTwoWay", twoWayScriptingObject);
browser.CoreWebView2.Settings.IsZoomControlEnabled = true;
}, TaskScheduler.FromCurrentSynchronizationContext());
}
await isInitialized;
}

Expand Down
7 changes: 5 additions & 2 deletions src/Notifications/NotificationCenterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ internal NotificationCenterController(DynamoView view, DynamoLogger dynLogger)
// This ensures no network traffic when Notification center feature is turned off
if (dynamoViewModel.PreferenceSettings.EnableNotificationCenter && !dynamoViewModel.Model.NoNetworkMode )
{
InitializeBrowserAsync();
notificationUIPopup.webView.Loaded += InitializeBrowserAsync;
RequestNotifications();
}
}

private async void InitializeBrowserAsync()
private async void InitializeBrowserAsync(object sender, RoutedEventArgs e)
{
if (isDisposing) return;

if (webBrowserUserDataFolder != null)
{
//This indicates in which location will be created the WebView2 cache folder
Expand Down Expand Up @@ -302,6 +304,7 @@ private void Dispose(bool disposing)
if (notificationUIPopup.webView != null)
{
notificationUIPopup.webView.Visibility = Visibility.Hidden;
notificationUIPopup.webView.Loaded -= InitializeBrowserAsync;
if (notificationUIPopup.webView.CoreWebView2 != null)
{
notificationUIPopup.webView.CoreWebView2.Stop();
Expand Down

0 comments on commit 009732f

Please sign in to comment.