mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
fixing embedding Python multithread problems
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using WinAlfred.Plugin;
|
||||
|
||||
namespace WinAlfred.PluginLoader
|
||||
{
|
||||
public class PythonPluginLoader : BasePluginLoader
|
||||
{
|
||||
|
||||
public override List<PluginPair> LoadPlugin()
|
||||
{
|
||||
List<PluginPair> plugins = new List<PluginPair>();
|
||||
@@ -21,9 +21,12 @@ namespace WinAlfred.PluginLoader
|
||||
};
|
||||
plugins.Add(pair);
|
||||
}
|
||||
|
||||
foreach (IPlugin plugin in plugins.Select(pluginPair => pluginPair.Plugin))
|
||||
{
|
||||
new Thread(plugin.Init).Start();
|
||||
}
|
||||
return plugins;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace WinAlfred.PluginLoader
|
||||
|
||||
[DllImport("PyWinAlfred.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
private extern static IntPtr ExecPython(string directory, string file, string query);
|
||||
[DllImport("PyWinAlfred.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
private extern static void InitPythonEnv();
|
||||
|
||||
public PythonPluginWrapper(PluginMetadata metadata)
|
||||
{
|
||||
@@ -27,7 +29,7 @@ namespace WinAlfred.PluginLoader
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
||||
InitPythonEnv();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user