Skip to content

Commit 80c283a

Browse files
committed
Improve code quality
1 parent 8bac530 commit 80c283a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Flow.Launcher/Helper/WallpaperPathRetrieval.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using System.Threading;
56
using System.Windows;
67
using System.Windows.Media;
78
using System.Windows.Media.Imaging;
@@ -16,7 +17,7 @@ public static class WallpaperPathRetrieval
1617

1718
private const int MaxCacheSize = 3;
1819
private static readonly Dictionary<(string, DateTime), ImageBrush> WallpaperCache = new();
19-
private static readonly object CacheLock = new();
20+
private static readonly Lock CacheLock = new();
2021

2122
public static Brush GetWallpaperBrush()
2223
{
@@ -56,7 +57,7 @@ public static Brush GetWallpaperBrush()
5657

5758
if (originalWidth == 0 || originalHeight == 0)
5859
{
59-
App.API.LogInfo(ClassName, $"Failed to load bitmap: Width={originalWidth}, Height={originalHeight}");
60+
App.API.LogError(ClassName, $"Failed to load bitmap: Width={originalWidth}, Height={originalHeight}");
6061
return new SolidColorBrush(Colors.Transparent);
6162
}
6263

@@ -104,13 +105,13 @@ public static Brush GetWallpaperBrush()
104105

105106
private static Color GetWallpaperColor()
106107
{
107-
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Colors", false);
108+
using var key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Colors", false);
108109
var result = key?.GetValue("Background", null);
109110
if (result is string strResult)
110111
{
111112
try
112113
{
113-
var parts = strResult.Trim().Split(new[] { ' ' }, 3).Select(byte.Parse).ToList();
114+
var parts = strResult.Trim().Split([' '], 3).Select(byte.Parse).ToList();
114115
return Color.FromRgb(parts[0], parts[1], parts[2]);
115116
}
116117
catch (Exception ex)

0 commit comments

Comments
 (0)