private void Init()
{
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (s, e) =>
{
this.MainStackPanel.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (ThreadStart)delegate()
{
Load();
});
};
worker.RunWorkerAsync();
} //指定对一个WPF前台界面做异步处理,即该界面内部的生成会在界面初始化之后进行
TextBlock Block = new TextBlock();
Block.Text = "这是一个异步产生的控件"
this.MainStackPanel.Childre.Add(Block);
}
private void Load()
{TextBlock Block = new TextBlock();
Block.Text = "这是一个异步产生的控件"
this.MainStackPanel.Childre.Add(Block);
}