Skip to content

Commit

Permalink
update (#14710)
Browse files Browse the repository at this point in the history
Co-authored-by: pinzart <[email protected]>
  • Loading branch information
pinzart90 and pinzart authored Dec 8, 2023
1 parent 3ea1c5c commit d5e6c9b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Windows;
using System.Windows.Controls;
using Dynamo.Logging;
using Dynamo.Models;
using Dynamo.Utilities;
using DynamoUtilities;
using Microsoft.Web.WebView2.Core;
Expand Down Expand Up @@ -216,7 +217,14 @@ public void Dispose()
#region ILogSource Implementation
private void Log(string message)
{
viewModel.MessageLogged?.Invoke(LogMessage.Info(message));
if (DynamoModel.IsTestMode)
{
System.Console.WriteLine(message);
}
else
{
viewModel?.MessageLogged?.Invoke(LogMessage.Info(message));
}
}
#endregion
}
Expand Down
15 changes: 14 additions & 1 deletion src/Notifications/NotificationCenterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Microsoft.Web.WebView2.Wpf;
using Dynamo.Utilities;
using Dynamo.Configuration;
using Dynamo.Models;

namespace Dynamo.Notifications
{
Expand Down Expand Up @@ -345,10 +346,22 @@ public void Dispose()
{
if (initState == AsyncMethodState.Started)
{
logger?.Log("NotificationCenterController is being disposed but async initialization is still not done");
Log("NotificationCenterController is being disposed but async initialization is still not done");
}
Dispose(true);
GC.SuppressFinalize(this);
}

private void Log(string msg)
{
if (DynamoModel.IsTestMode)
{
System.Console.WriteLine(msg);
}
else
{
logger?.Log(msg);
}
}
}
}
6 changes: 2 additions & 4 deletions test/DynamoCoreWpfTests/Utility/DispatcherUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public static class DispatcherUtil
/// <summary>
/// Force the Dispatcher to empty it's queue
/// </summary>
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public static void DoEvents()
{
var frame = new DispatcherFrame();
Expand All @@ -24,14 +23,13 @@ public static void DoEvents()
}

/// <summary>
/// Force the Dispatcher to empty it's queue every 100 ms for a maximum 4 seconds or until
/// Force the Dispatcher to empty it's queue every 100 ms for a maximum 20 seconds or until
/// the check function returns true.
/// </summary>
/// <param name="check">When check returns true, the even loop is stopped.</param>
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public static void DoEventsLoop(Func<bool> check = null)
{
const int max_count = 40;
const int max_count = 200;

int count = 0;
while (true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ public void CanHandleDocsEventTriggeredFromDynamoViewModel()
// Act
var tabsBeforeExternalEventTrigger = this.ViewModel.SideBarTabItems.Count;
this.ViewModel.OpenDocumentationLinkCommand.Execute(docsEvent);

WaitForWebView2Initialization();

var tabsAfterExternalEventTrigger = this.ViewModel.SideBarTabItems.Count;
var htmlContent = GetSidebarDocsBrowserContents();

Expand Down

0 comments on commit d5e6c9b

Please sign in to comment.