Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
fix long loading time of the "System Information" page for weak PCs
Greedeks7c7a0051c8f7
diff --git a/.Source/GTweak/Core/ViewModel/DataSystemVM.cs b/.Source/GTweak/Core/ViewModel/DataSystemVM.csindex 6c269501..4e20ff8f 100644--- a/.Source/GTweak/Core/ViewModel/DataSystemVM.cs+++ b/.Source/GTweak/Core/ViewModel/DataSystemVM.cs@@ -65,8 +65,8 @@ namespace GTweak.Core.ViewModel{CreateModelCollection("OSName", SystemDiagnostics.HardwareData.OS.Name, "unknown_information_systemInformatin"),CreateModelCollection("OSVersion", SystemDiagnostics.HardwareData.OS.Version, "unknown_information_systemInformatin"),- CreateModelCollection("Processes", new MonitoringService().GetNumberRunningProcesses),- CreateModelCollection("Services", new MonitoringService().GetNumberRunningService),+ CreateModelCollection("Processes", MonitoringService.GetNumberRunningProcesses),+ CreateModelCollection("Services", MonitoringService.GetNumberRunningService),CreateModelCollection("Bios", SystemDiagnostics.HardwareData.Bios, "no_device_information_systemInformatin"),CreateModelCollection("Mode", SystemDiagnostics.HardwareData.BiosMode, "unknown_information_systemInformatin"),CreateModelCollection("Motherboard", SystemDiagnostics.HardwareData.Motherboard, "no_device_information_systemInformatin"),diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csprojindex 5d343c34..d2e38596 100644--- a/.Source/GTweak/GTweak.csproj+++ b/.Source/GTweak/GTweak.csproj@@ -49,7 +49,7 @@<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "><PlatformTarget>x64</PlatformTarget><DebugType>pdbonly</DebugType>- <Optimize>false</Optimize>+ <Optimize>true</Optimize><OutputPath>bin\Release\</OutputPath><DefineConstants>TRACE</DefineConstants><ErrorReport>prompt</ErrorReport>diff --git a/.Source/GTweak/Utilities/Configuration/MonitoringService.cs b/.Source/GTweak/Utilities/Configuration/MonitoringService.csindex 423cc564..bcd2b4e5 100644--- a/.Source/GTweak/Utilities/Configuration/MonitoringService.cs+++ b/.Source/GTweak/Utilities/Configuration/MonitoringService.cs@@ -15,8 +15,8 @@ namespace GTweak.Utilities.Configurationprivate readonly List<(ManagementEventWatcher watcher, EventArrivedEventHandler handler)> _watcherHandler = new List<(ManagementEventWatcher watcher, EventArrivedEventHandler handler)>();private readonly ServiceController[] _servicesList = ServiceController.GetServices();- internal string GetNumberRunningProcesses => GetProcessCount().Result;- internal string GetNumberRunningService => GetServicesCount().Result;+ internal static string GetNumberRunningProcesses { get; set; } = "...";+ internal static string GetNumberRunningService { get; set; } = "...";internal int GetMemoryUsage => GetPhysicalAvailableMemory().Result;internal static int GetProcessorUsage { get; private set; } = 1;@@ -60,8 +60,7 @@ namespace GTweak.Utilities.Configuration[DllImport("kernel32.dll", SetLastError = true)]private static extern bool GetSystemTimes(out SystemTime lpIdleTime, out SystemTime lpKernelTime, out SystemTime lpUserTime);-- private async Task<string> GetProcessCount()+ internal async Task<string> GetProcessCount(){return await Task.Run(() =>{@@ -92,7 +91,7 @@ namespace GTweak.Utilities.Configuration}).ConfigureAwait(false);}- private async Task<string> GetServicesCount()+ internal async Task<string> GetServicesCount(){return await Task.Run(() =>{@@ -186,21 +185,17 @@ namespace GTweak.Utilities.Configurationinternal void StopDeviceMonitoring(){- Task.Run(() =>+ foreach ((ManagementEventWatcher watcher, EventArrivedEventHandler handler) in _watcherHandler){- Parallel.ForEach(_watcherHandler, tuple =>+ try{- var (watcher, handler) = tuple;- try- {- watcher.EventArrived -= handler;- watcher.Stop();- watcher.Dispose();- }- catch (Exception ex) { ErrorLogging.LogDebug(ex); }- });- _watcherHandler.Clear();- });+ watcher.EventArrived -= handler;+ watcher.Stop();+ watcher.Dispose();+ }+ catch (Exception ex) { ErrorLogging.LogDebug(ex); }+ }+ _watcherHandler.Clear();}}}diff --git a/.Source/GTweak/View/DataSystemView.xaml b/.Source/GTweak/View/DataSystemView.xamlindex 6f7ab78e..55d414e8 100644--- a/.Source/GTweak/View/DataSystemView.xaml+++ b/.Source/GTweak/View/DataSystemView.xaml@@ -69,10 +69,10 @@<TextBlock HorizontalAlignment="Left" FontFamily="{StaticResource Jura}" FontSize="14" Foreground="{StaticResource Color_Inactive}" Margin="0,5,0,0"><Run Text="{DynamicResource label_proc_systemInformation}"/>- <Run Text="{Binding [Processes].Data, StringFormat=' {0}'}"/>+ <Run x:Name="Processes" Text="{Binding [Processes].Data, StringFormat=' {0}'}"/><Run Text=" • "/><Run Text="{DynamicResource label_svc_systemInformation}"/>- <Run Text="{Binding [Services].Data, StringFormat=' {0}'}"/>+ <Run x:Name="Services" Text="{Binding [Services].Data, StringFormat=' {0}'}"/></TextBlock></StackPanel></Grid>diff --git a/.Source/GTweak/View/DataSystemView.xaml.cs b/.Source/GTweak/View/DataSystemView.xaml.csindex 1e4c677a..6e2e7ef1 100644--- a/.Source/GTweak/View/DataSystemView.xaml.cs+++ b/.Source/GTweak/View/DataSystemView.xaml.cs@@ -6,6 +6,7 @@ using GTweak.Utilities.Helpers;using GTweak.Utilities.Managers;using System;using System.Collections.Generic;+using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Controls.Primitives;@@ -32,16 +33,19 @@ namespace GTweak.ViewApp.LanguageChanged += delegate{- Dispatcher.Invoke(() =>+ Dispatcher.BeginInvoke(new Action(() =>{if (new Dictionary<SystemDiagnostics.ConnectionStatus, string>{{ SystemDiagnostics.ConnectionStatus.Lose, "connection_lose_systemInformation" },{ SystemDiagnostics.ConnectionStatus.Block, "connection_block_systemInformation" },{ SystemDiagnostics.ConnectionStatus.Limited, "connection_limited_systemInformation" }- }.TryGetValue(SystemDiagnostics.CurrentConnection, out string resourceKey)) { SystemDiagnostics.HardwareData.UserIPAddress = (string)FindResource(resourceKey); }- DataContext = new DataSystemVM();- });+ }.TryGetValue(SystemDiagnostics.CurrentConnection, out string resourceKey))+ {+ SystemDiagnostics.HardwareData.UserIPAddress = (string)FindResource(resourceKey);+ DataContext = new DataSystemVM();+ }+ }));};_timer = new TimerControlManager(TimeSpan.Zero, TimerControlManager.TimerMode.CountUp, async time =>@@ -50,6 +54,11 @@ namespace GTweak.View{await backgroundQueue.QueueTask(async delegate { await _systemDiagnostics.GetTotalProcessorUsage(); });AnimationProgressBars();+ _ = Dispatcher.BeginInvoke(new Action(async () =>+ {+ Processes.Text = MonitoringService.GetNumberRunningProcesses = await Task.Run(() => _systemDiagnostics.GetProcessCount());+ Services.Text = MonitoringService.GetNumberRunningService = await Task.Run(() => _systemDiagnostics.GetServicesCount());+ }));}else if ((int)time.TotalSeconds % 5 == 0){@@ -70,11 +79,11 @@ namespace GTweak.Viewprivate void AnimationProgressBars(){- Dispatcher.Invoke(() =>+ Dispatcher.BeginInvoke(new Action(() =>{CPULoad.BeginAnimation(ProgressBar.ValueProperty, FactoryAnimation.CreateIn(CPULoad.Value, MonitoringService.GetProcessorUsage, 0.2));RAMLoad.BeginAnimation(ProgressBar.ValueProperty, FactoryAnimation.CreateIn(RAMLoad.Value, _systemDiagnostics.GetMemoryUsage, 0.2));- });+ }));}private void AnimationPopup(){diff --git a/.Source/GTweak/Windows/LoadingWindow.xaml.cs b/.Source/GTweak/Windows/LoadingWindow.xaml.csindex 3dcfd416..3d436ab5 100644--- a/.Source/GTweak/Windows/LoadingWindow.xaml.cs+++ b/.Source/GTweak/Windows/LoadingWindow.xaml.cs@@ -60,6 +60,8 @@ namespace GTweak.Windows() => ExecuteWithLogging(new SystemTweaks().ViewConfigTick, nameof(SystemTweaks.ViewConfigTick)));+ ExecuteWithLogging(() => MonitoringService.GetNumberRunningProcesses = new SystemDiagnostics().GetProcessCount().Result, nameof(MonitoringService.GetProcessCount));+ ExecuteWithLogging(() => MonitoringService.GetNumberRunningService = new SystemDiagnostics().GetServicesCount().Result, nameof(MonitoringService.GetServicesCount));ExecuteWithLogging(() => new MonitoringService().GetTotalProcessorUsage().GetAwaiter().GetResult(), nameof(MonitoringService.GetTotalProcessorUsage));}