mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[PTRun][Settings][Program] Fix 100% CPU load issue (#17414)
* [PTRun][Program]Don't reload on settings change * [PTRun][Settings] Don't trigger saves on visual property changes * [PTRun][Settings] Fix manipulation of searched plugins * [PTRun][Settings] Don't reload settings if we wrote recently * fix PR comments nit
This commit is contained in:
@@ -19,15 +19,31 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
private readonly ObservableCollection<Tuple<string, string>> searchResultPreferencesOptions;
|
||||
private readonly ObservableCollection<Tuple<string, string>> searchTypePreferencesOptions;
|
||||
|
||||
private int _lastIPCMessageSentTick;
|
||||
|
||||
// Keep track of the last IPC Message that was sent.
|
||||
private int SendDefaultIPCMessageTimed(string msg)
|
||||
{
|
||||
_lastIPCMessageSentTick = Environment.TickCount;
|
||||
return ShellPage.SendDefaultIPCMessage(msg);
|
||||
}
|
||||
|
||||
public PowerLauncherPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
var settingsUtils = new SettingsUtils();
|
||||
_lastIPCMessageSentTick = Environment.TickCount;
|
||||
PowerLauncherSettings settings = settingsUtils.GetSettingsOrDefault<PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
|
||||
ViewModel = new PowerLauncherViewModel(settings, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, App.IsDarkTheme);
|
||||
ViewModel = new PowerLauncherViewModel(settings, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), SendDefaultIPCMessageTimed, App.IsDarkTheme);
|
||||
DataContext = ViewModel;
|
||||
_ = Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", () =>
|
||||
{
|
||||
if (Environment.TickCount < _lastIPCMessageSentTick + 500)
|
||||
{
|
||||
// Don't try to update data from the file if we tried to write to it through IPC in the last 500 milliseconds.
|
||||
return;
|
||||
}
|
||||
|
||||
PowerLauncherSettings powerLauncherSettings = null;
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user