开发者

UI thread for each MAF AddIn

I work with the MAF in WPF and I have problems with the UI threads. I would like that each AddIn that I activate become a unique UI thread.

Why do I want that you probably wondering? I try to explain :-)

I have a host application which is a container for addins. Different people developing addins for the host. If a developer start a long procedure in their addin and they fo开发者_Go百科rget to Invoke or start the procedure in a thread, the host will freeze because the host and the addins share the same UI thread.

Every addin run in a seperatly appdomain. About every hint I would be happy.


you could try the following approach:

Thread thread = new Thread(() =>
{
 Window1 w = new Window1();
 w.Show();

 //make sure to stop the Dispatcher when window is closed
 w.Closed += (s, e) => w.Dispatcher.InvokeShutdown();
 //start the message pump
 System.Windows.Threading.Dispatcher.Run();
});

thread.SetApartmentState(ApartmentState.STA);
thread.Start();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜