This commit is contained in:
Yu Leng (from Dev Box)
2025-10-16 16:48:51 +08:00
parent c020d0b75b
commit f83f0b08f2
3 changed files with 6 additions and 12 deletions

View File

@@ -252,11 +252,6 @@ namespace PowerDisplay.Helpers
// Release save permission even on error
Interlocked.Exchange(ref _isSaving, 0);
}
catch
{
// Ensure we never crash on save
Interlocked.Exchange(ref _isSaving, 0);
}
await Task.CompletedTask; // Suppress async warning
}

View File

@@ -21,10 +21,6 @@
<ProjectPriFileName>PowerToys.PowerDisplay.pri</ProjectPriFileName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<!-- Disable StyleCop for this project -->
<DisableStyleCop>true</DisableStyleCop>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
<ItemGroup>
<Page Remove="PowerDisplayXAML\App.xaml" />

View File

@@ -692,10 +692,13 @@ public class MainViewModel : INotifyPropertyChanged, IDisposable
try
{
// Use Task.Run to avoid deadlock and wait with timeout
var flushTask = Task.Run(async () => await _settingsManager?.FlushAsync());
if (!flushTask.Wait(TimeSpan.FromSeconds(2)))
if (_settingsManager != null)
{
Logger.LogWarning("Settings flush timed out during dispose");
var flushTask = Task.Run(async () => await _settingsManager.FlushAsync());
if (!flushTask.Wait(TimeSpan.FromSeconds(2)))
{
Logger.LogWarning("Settings flush timed out during dispose");
}
}
}
catch (Exception ex)