diff --git a/src/DynamoUtilities/CLIWrapper.cs b/src/DynamoUtilities/CLIWrapper.cs index b6040df6a1b..e4c851ad076 100644 --- a/src/DynamoUtilities/CLIWrapper.cs +++ b/src/DynamoUtilities/CLIWrapper.cs @@ -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) diff --git a/src/LibraryViewExtensionWebView2/LibraryViewController.cs b/src/LibraryViewExtensionWebView2/LibraryViewController.cs index 2149c811191..155e4d84f02 100644 --- a/src/LibraryViewExtensionWebView2/LibraryViewController.cs +++ b/src/LibraryViewExtensionWebView2/LibraryViewController.cs @@ -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; } diff --git a/src/Notifications/NotificationCenterController.cs b/src/Notifications/NotificationCenterController.cs index 3919f5426ba..a67ed58fd1b 100644 --- a/src/Notifications/NotificationCenterController.cs +++ b/src/Notifications/NotificationCenterController.cs @@ -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 @@ -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();