Hosting WPF plugin cross-process issue

天大地大妈咪最大 提交于 2019-12-23 02:43:07

问题


I use an approach similar to http://www.codeproject.com/Articles/516431/Baktun-Shell-Hosting-WPF-Child-Windows-in-Another to host WPF applications (plugins) in another process via the AddInHost (derived from HwndHost) class.

This works fine so far as long as I don't suspend the child process. If I do so then also the parent process is frozen. The reason for this is that the parent/child processes are sharing the same (synchronous) Input Queue: Good or evil - SetParent() win32 API between different processes

I have already tried to decouple the two processes before I suspend the plugin process with the SetParent Win32 function but even the plugin is then decoupled from the host-application it does not help to get rid of the problem:

public static void Decouple(HwndHost hwndHost)
{
  SetParent(hwndHost.Handle, IntPtr.Zero);
}

Any ideas what I am missing here to separate the two processes so that they don't share the same input queue any longer?


回答1:


For me the solution was to use AttachThreadInput Win32 API function to detach the plugin HwndHost input queue



来源:https://stackoverflow.com/questions/40525884/hosting-wpf-plugin-cross-process-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!