mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 05:06:36 +02:00
Makes AllPlugins single tone thread safe (#10121)
This commit is contained in:
@@ -24,6 +24,7 @@ namespace PowerLauncher.Plugin
|
|||||||
{
|
{
|
||||||
private static readonly IFileSystem FileSystem = new FileSystem();
|
private static readonly IFileSystem FileSystem = new FileSystem();
|
||||||
private static readonly IDirectory Directory = FileSystem.Directory;
|
private static readonly IDirectory Directory = FileSystem.Directory;
|
||||||
|
private static readonly object AllPluginsLock = new object();
|
||||||
|
|
||||||
private static IEnumerable<PluginPair> _contextMenuPlugins = new List<PluginPair>();
|
private static IEnumerable<PluginPair> _contextMenuPlugins = new List<PluginPair>();
|
||||||
|
|
||||||
@@ -44,7 +45,13 @@ namespace PowerLauncher.Plugin
|
|||||||
{
|
{
|
||||||
if (_allPlugins == null)
|
if (_allPlugins == null)
|
||||||
{
|
{
|
||||||
_allPlugins = PluginsLoader.Plugins(PluginConfig.Parse(Directories));
|
lock (AllPluginsLock)
|
||||||
|
{
|
||||||
|
if (_allPlugins == null)
|
||||||
|
{
|
||||||
|
_allPlugins = PluginsLoader.Plugins(PluginConfig.Parse(Directories));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _allPlugins;
|
return _allPlugins;
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ namespace PowerLauncher.Plugin
|
|||||||
public static IEnumerable<PluginPair> CSharpPlugins(List<PluginMetadata> source)
|
public static IEnumerable<PluginPair> CSharpPlugins(List<PluginMetadata> source)
|
||||||
{
|
{
|
||||||
var plugins = new List<PluginPair>();
|
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)
|
foreach (var metadata in metadatas)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user