2
我有加载一些插件的能力(DLL的)的应用程序。它正在使用WPF。当插件创建UI控件时,问题是滞后的。WPF插件创建UI策略
在主应用程序,我有一些控制。我将这些引用传递给插件。当我调用插件的Show()方法时,他必须将特殊的UI控件添加到我的主应用程序中。
我怎样才能在后台线程创建插件的UI控件,并添加他们的主要应用,如果应用程序主UI线程没有访问,S至极被另一个线程创建的任何控制?
我使用此代码在主要应用:
if (!module.IsInitialized())
{
this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new Action(
delegate()
{
module.InitializeComponents();
module.ShowModule();
}
));
}
其中插件初始化的方法是:
public void InitializeComponents()
{
MyBodyArea = new SERPBodyArea(); // there is UI control
MyBottomArea = new SERPBottomArea(); // there is UI control
MyHeaderRibbon = new SERPXamRibbon(); // there is UI control
_IsInitialized = true;
}
所以当插件创建UI控件,我主要的应用程序被冻结。有没有办法在后台线程中创建它并将其添加到主应用程序窗口?
谢谢。对不起,我的英文不好:(
感谢回复。在UI线程中调用的模块初始化方法中,我只创建UI控件(数据结构,计算插入后台线程)。模块UI控件是第三方数据网格,功能区等。因此,使用我强大的PC配置进行初始化大约需要2-3秒。 – Dmitriy 2011-01-10 06:15:18