Invoking a Multi-Threaded DLL at Run-Time

不问归期 提交于 2019-12-06 05:35:32

It's difficult to guess what you have in dll but eventually your dll code + exposed in your question:

dllWinForm.Show();  

should eventually have been after juxtaposing:

new Thread
      (   
         () => new Form().ShowDialog()
       )
       .Start();  

Probably, you should change dllWinForm.Show(); by dllWinForm.ShowDialog().Start();

ShowDialog(), in contrast with Show(), starts its own message pumping and returns only when explicitly closed.

Update (in respnse to comment):
It is not absolutely necessary to launch a form from UI.
Since you are on .NET 4.5, it is probably simpler to use WPF (instead of Windows Form) form.
Here is the code for WPF form which, in order to adjust for Windows Form, you should change Dispatcher parts by initializing WindowsFormsSynchronizationContext

Though, IMO, WinForms code will be much more complex.

Change the return type of Execute to Task and await it.

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