Skip to content

Portable Tool for an Ideal Windows Setup

changed analyze method synchronous, remove Parallel.Invoke

Greedeks4fb50ea76b6e
diff --git a/.Source/GTweak/Core/Base/ViewModelPageBase.cs b/.Source/GTweak/Core/Base/ViewModelPageBase.cs
index 17b44db6..003e73b7 100644
--- a/.Source/GTweak/Core/Base/ViewModelPageBase.cs
+++ b/.Source/GTweak/Core/Base/ViewModelPageBase.cs
@@ -1,7 +1,6 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
-using System.Threading.Tasks;
namespace GTweak.Core.Base
{
@@ -23,38 +22,38 @@ namespace GTweak.Core.Base
public ObservableCollection<TModel> Toggles { get; private set; }
public TModel this[string name] => Toggles.FirstOrDefault(d => d.Name == name);
-
protected abstract Dictionary<string, object> GetControlStates();
-
protected abstract void Analyze(TTweaksClass tweaks);
protected ViewModelPageBase()
{
TTweaksClass tweaks = new TTweaksClass();
- Parallel.Invoke(() => Analyze(tweaks));
-
- Toggles = new ObservableCollection<TModel>(
- GetControlStates().Select(kvp =>
- {
- TModel model = new TModel { Name = kvp.Key };
-
- switch (kvp.Value)
- {
- case bool b:
- model.State = b;
- break;
- case double d when model is ITypedPageItem<double> doubleItem:
- doubleItem.Value = d;
- break;
- case string s when model is ITypedPageItem<string> stringItem:
- stringItem.Value = s;
- break;
- }
-
- return model;
- }));
+ Analyze(tweaks);
+ Toggles = new ObservableCollection<TModel>(GetControlStates().Select(kvp => CreateModelFromState(kvp.Key, kvp.Value)));
OnPropertyChanged(nameof(Toggles));
}
+
+ private TModel CreateModelFromState(string name, object parameter)
+ {
+ TModel model = new TModel { Name = name };
+
+ switch (parameter)
+ {
+ case bool b:
+ model.State = b;
+ break;
+ case double d when model is ITypedPageItem<double> doubleItem:
+ doubleItem.Value = d;
+ break;
+ case string s when model is ITypedPageItem<string> stringItem:
+ stringItem.Value = s;
+ break;
+ default:
+ break;
+ }
+
+ return model;
+ }
}
}
diff --git a/.Source/GTweak/View/ConfidentialityView.xaml.cs b/.Source/GTweak/View/ConfidentialityView.xaml.cs
index b75e5e5b..50a23414 100644
--- a/.Source/GTweak/View/ConfidentialityView.xaml.cs
+++ b/.Source/GTweak/View/ConfidentialityView.xaml.cs
@@ -1,4 +1,3 @@
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -45,8 +44,6 @@ namespace GTweak.View
{
NotificationManager.Show().WithDelay(300).Perform(action);
}
-
- Parallel.Invoke(async delegate { await Task.Delay(1000); _confTweaks.AnalyzeAndUpdate(); });
}
}
}
diff --git a/.Source/GTweak/View/InterfaceView.xaml.cs b/.Source/GTweak/View/InterfaceView.xaml.cs
index 3f711ed9..9b607af1 100644
--- a/.Source/GTweak/View/InterfaceView.xaml.cs
+++ b/.Source/GTweak/View/InterfaceView.xaml.cs
@@ -1,5 +1,4 @@
using System.Diagnostics;
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -58,8 +57,6 @@ namespace GTweak.View
{
NotificationManager.Show().WithDelay(300).Perform(action);
}
-
- Parallel.Invoke(async delegate { await Task.Delay(1000); _intfTweaks.AnalyzeAndUpdate(); });
}
}
}
diff --git a/.Source/GTweak/View/ServicesView.xaml.cs b/.Source/GTweak/View/ServicesView.xaml.cs
index 895344c7..252c481a 100644
--- a/.Source/GTweak/View/ServicesView.xaml.cs
+++ b/.Source/GTweak/View/ServicesView.xaml.cs
@@ -1,4 +1,3 @@
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -40,8 +39,6 @@ namespace GTweak.View
_svcTweaks.ApplyTweaks(((ToggleButton)sender).Name, ((ToggleButton)sender).State);
NotificationManager.Show().WithDelay(300).Restart();
-
- Parallel.Invoke(async delegate { await Task.Delay(((ToggleButton)sender).Name.Contains("15") ? 2000 : 1000); _svcTweaks.AnalyzeAndUpdate(); });
}
}
}
diff --git a/.Source/GTweak/View/SystemView.xaml.cs b/.Source/GTweak/View/SystemView.xaml.cs
index 49735e9d..50a4f728 100644
--- a/.Source/GTweak/View/SystemView.xaml.cs
+++ b/.Source/GTweak/View/SystemView.xaml.cs
@@ -1,4 +1,3 @@
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -59,8 +58,6 @@ namespace GTweak.View
{
NotificationManager.Show().WithDelay(300).Perform(action);
}
-
- Parallel.Invoke(async delegate { await Task.Delay(1000); _sysTweaks.AnalyzeAndUpdate(); });
}
else
{