From 0816fdf3188f0ba9867efa223b2da094584d3cbd Mon Sep 17 00:00:00 2001 From: bao-qian Date: Thu, 21 Jul 2016 20:07:23 +0100 Subject: [PATCH] Program plugin: remove lock lock is not needed since assignment is atomic --- Plugins/Wox.Plugin.Program/Main.cs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/Plugins/Wox.Plugin.Program/Main.cs b/Plugins/Wox.Plugin.Program/Main.cs index 11b4572c81..c0c09da004 100644 --- a/Plugins/Wox.Plugin.Program/Main.cs +++ b/Plugins/Wox.Plugin.Program/Main.cs @@ -14,7 +14,6 @@ namespace Wox.Plugin.Program { public class Main : ISettingProvider, IPlugin, IPluginI18n, IContextMenu, ISavable { - private static readonly object IndexLock = new object(); private static List _programs = new List(); private PluginInitContext _context; @@ -88,24 +87,21 @@ namespace Wox.Plugin.Program public static void IndexPrograms() { - lock (IndexLock) + var sources = DefaultProgramSources(); + if (_settings.ProgramSources != null && + _settings.ProgramSources.Count(o => o.Enabled) > 0) { - var sources = DefaultProgramSources(); - if (_settings.ProgramSources != null && - _settings.ProgramSources.Count(o => o.Enabled) > 0) - { - sources.AddRange(_settings.ProgramSources); - } - - _programs = sources.AsParallel() - .SelectMany(s => s.LoadPrograms()) - // filter duplicate program - .GroupBy(x => new { ExecutePath = x.Path, ExecuteName = x.ExecutableName }) - .Select(g => g.First()) - .ToList(); - - _cache.Programs = _programs; + sources.AddRange(_settings.ProgramSources); } + + _programs = sources.AsParallel() + .SelectMany(s => s.LoadPrograms()) + // filter duplicate program + .GroupBy(x => new { ExecutePath = x.Path, ExecuteName = x.ExecutableName }) + .Select(g => g.First()) + .ToList(); + + _cache.Programs = _programs; } ///