mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
Makes AllPlugins single tone thread safe (#10121)
This commit is contained in:
parent
38eb6ad062
commit
964286ab99
@ -24,6 +24,7 @@ namespace PowerLauncher.Plugin
|
||||
{
|
||||
private static readonly IFileSystem FileSystem = new FileSystem();
|
||||
private static readonly IDirectory Directory = FileSystem.Directory;
|
||||
private static readonly object AllPluginsLock = new object();
|
||||
|
||||
private static IEnumerable<PluginPair> _contextMenuPlugins = new List<PluginPair>();
|
||||
|
||||
@ -44,7 +45,13 @@ namespace PowerLauncher.Plugin
|
||||
{
|
||||
if (_allPlugins == null)
|
||||
{
|
||||
_allPlugins = PluginsLoader.Plugins(PluginConfig.Parse(Directories));
|
||||
lock (AllPluginsLock)
|
||||
{
|
||||
if (_allPlugins == null)
|
||||
{
|
||||
_allPlugins = PluginsLoader.Plugins(PluginConfig.Parse(Directories));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _allPlugins;
|
||||
|
@ -27,7 +27,9 @@ namespace PowerLauncher.Plugin
|
||||
public static IEnumerable<PluginPair> CSharpPlugins(List<PluginMetadata> source)
|
||||
{
|
||||
var plugins = new List<PluginPair>();
|
||||
var metadatas = source.Where(o => o.Language.ToUpperInvariant() == AllowedLanguage.CSharp);
|
||||
var metadatas = source
|
||||
.Where(o => o.Language.ToUpperInvariant() == AllowedLanguage.CSharp)
|
||||
.ToList();
|
||||
|
||||
foreach (var metadata in metadatas)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user