From 351e75996c96d782ce9c0e5b5fab6774aec02c67 Mon Sep 17 00:00:00 2001 From: Stefan Kert Date: Fri, 6 Oct 2017 22:56:27 +0200 Subject: [PATCH] First attempt to fix performance issues --- BuildVision.UI/Common/Logging/TraceManager.cs | 48 ++++++++++--------- BuildVision/Helpers/ProjectExtensions.cs | 6 ++- BuildVision/Tool/Tool.cs | 22 +++++---- 3 files changed, 43 insertions(+), 33 deletions(-) diff --git a/BuildVision.UI/Common/Logging/TraceManager.cs b/BuildVision.UI/Common/Logging/TraceManager.cs index c5404353..d0d481d9 100644 --- a/BuildVision.UI/Common/Logging/TraceManager.cs +++ b/BuildVision.UI/Common/Logging/TraceManager.cs @@ -60,37 +60,41 @@ public static void Trace(string message, EventLogEntryType type) private static void TraceAction(string message, EventLogEntryType type) { - // ActivityLog works if devenv.exe started with /log switch. - // Read more https://msdn.microsoft.com/en-us/library/ms241272.aspx. - switch (type) + System.Threading.Tasks.Task.Run(() => { - case EventLogEntryType.Error: - ActivityLog.LogError(Resources.ProductName, message); + + // ActivityLog works if devenv.exe started with /log switch. + // Read more https://msdn.microsoft.com/en-us/library/ms241272.aspx. + switch (type) + { + case EventLogEntryType.Error: + ActivityLog.LogError(Resources.ProductName, message); #if DEBUG - System.Diagnostics.Trace.TraceError(message); - MessageBox.Show(message, Resources.ProductName + " error", MessageBoxButton.OK, MessageBoxImage.Error); + System.Diagnostics.Trace.TraceError(message); + MessageBox.Show(message, Resources.ProductName + " error", MessageBoxButton.OK, MessageBoxImage.Error); #endif - break; + break; - case EventLogEntryType.Warning: - case EventLogEntryType.FailureAudit: - ActivityLog.LogWarning(Resources.ProductName, message); + case EventLogEntryType.Warning: + case EventLogEntryType.FailureAudit: + ActivityLog.LogWarning(Resources.ProductName, message); #if DEBUG - System.Diagnostics.Trace.TraceWarning(message); + System.Diagnostics.Trace.TraceWarning(message); #endif - break; + break; - case EventLogEntryType.Information: - case EventLogEntryType.SuccessAudit: - ActivityLog.LogInformation(Resources.ProductName, message); + case EventLogEntryType.Information: + case EventLogEntryType.SuccessAudit: + ActivityLog.LogInformation(Resources.ProductName, message); #if DEBUG - System.Diagnostics.Trace.TraceInformation(message); + System.Diagnostics.Trace.TraceInformation(message); #endif - break; + break; - default: - throw new ArgumentOutOfRangeException("type"); - } + default: + throw new ArgumentOutOfRangeException("type"); + } + }); } /// @@ -169,4 +173,4 @@ public static string ToLogString(this Exception ex, string additionalMessage) return msg.ToString(); } } -} \ No newline at end of file +} diff --git a/BuildVision/Helpers/ProjectExtensions.cs b/BuildVision/Helpers/ProjectExtensions.cs index f98cdc07..89492fb2 100644 --- a/BuildVision/Helpers/ProjectExtensions.cs +++ b/BuildVision/Helpers/ProjectExtensions.cs @@ -393,6 +393,10 @@ public static string GetExtenderNames(this Project project) return string.Join("; ", extenderNames); } + catch (ArgumentException ex) + { + return ""; // Leaving this in for now until visual studio team fixes the issue with extendernames + } catch (Exception ex) { ex.TraceUnknownException(); @@ -683,4 +687,4 @@ public static Microsoft.Build.Evaluation.Project GetMsBuildProject(this Project return new Microsoft.Build.Evaluation.Project(root); } } -} \ No newline at end of file +} diff --git a/BuildVision/Tool/Tool.cs b/BuildVision/Tool/Tool.cs index 83eecdf2..f6e4e4b2 100644 --- a/BuildVision/Tool/Tool.cs +++ b/BuildVision/Tool/Tool.cs @@ -33,6 +33,8 @@ using BuildVision.UI.Models; using BuildVision.UI.Settings.Models.ToolWindow; +using System.Threading.Tasks; + namespace BuildVision.Tool { public class Tool @@ -407,19 +409,19 @@ private void BuildEvents_OnBuildProcess() { try { - var labelsSettings = _viewModel.ControlSettings.BuildMessagesSettings; - string msg = _origTextCurrentState + BuildMessages.GetBuildBeginExtraMessage(_buildContext, labelsSettings); + Task.Run(() => + { + var labelsSettings = _viewModel.ControlSettings.BuildMessagesSettings; + string msg = _origTextCurrentState + BuildMessages.GetBuildBeginExtraMessage(_buildContext, labelsSettings); - _viewModel.TextCurrentState = msg; - OutputInStatusBar(msg, true); - //_dte.SuppressUI = false; + _viewModel.TextCurrentState = msg; + OutputInStatusBar(msg, true); + //_dte.SuppressUI = false; - var buildingProjects = _buildContext.BuildingProjects; - lock (((ICollection)buildingProjects).SyncRoot) - { + var buildingProjects = _buildContext.BuildingProjects; for (int i = 0; i < buildingProjects.Count; i++) buildingProjects[i].RaiseBuildElapsedTimeChanged(); - } + }); } catch (Exception ex) { @@ -541,4 +543,4 @@ private void ApplyToolWindowStateAction(WindowStateAction windowStateAction) } } } -} \ No newline at end of file +}