mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +01:00
fixing embedding Python multithread problems
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<Window x:Class="WinAlfred.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:winAlfred="clr-namespace:WinAlfred"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:winAlfred="clr-namespace:WinAlfred"
|
||||
Title="WinAlfred" Height="80" Width="525"
|
||||
Background="#ebebeb"
|
||||
Topmost="True"
|
||||
|
||||
@@ -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