Skip to content

Commit 85ad6b1

Browse files
authored
Merge pull request #78 from theClueless/programSyncIssue
fixed lock issue
2 parents 79706b4 + 8446c95 commit 85ad6b1

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Plugins/Wox.Plugin.Program/Main.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ public void Init(PluginInitContext context)
9090

9191
public static void IndexWin32Programs()
9292
{
93+
var win32S = Win32.All(_settings);
9394
lock (IndexLock)
9495
{
95-
_win32s = Win32.All(_settings);
96+
_win32s = win32S;
9697
}
9798
}
9899

@@ -101,17 +102,18 @@ public static void IndexUWPPrograms()
101102
var windows10 = new Version(10, 0);
102103
var support = Environment.OSVersion.Version.Major >= windows10.Major;
103104

105+
var applications = support ? UWP.All() : new UWP.Application[] { };
104106
lock (IndexLock)
105107
{
106-
_uwps = support ? UWP.All() : new UWP.Application[] { };
108+
_uwps = applications;
107109
}
108110
}
109111

110112
public static void IndexPrograms()
111113
{
112-
var t1 = Task.Run(() => { IndexWin32Programs(); });
114+
var t1 = Task.Run(IndexWin32Programs);
113115

114-
var t2 = Task.Run(() => { IndexUWPPrograms(); });
116+
var t2 = Task.Run(IndexUWPPrograms);
115117

116118
Task.WaitAll(t1, t2);
117119

Plugins/Wox.Plugin.Program/Programs/UWP.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ public static Application[] All()
165165
}
166166
#endif
167167
#if DEBUG //make developer aware and implement handling
168-
catch(Exception e)
168+
catch
169169
{
170-
throw e;
170+
throw;
171171
}
172172
#endif
173173
return u.Apps;
@@ -230,8 +230,7 @@ public override string ToString()
230230

231231
public override bool Equals(object obj)
232232
{
233-
var uwp = obj as UWP;
234-
if (uwp != null)
233+
if (obj is UWP uwp)
235234
{
236235
return FamilyName.Equals(uwp.FamilyName);
237236
}

0 commit comments

Comments
 (0)