我工作的一个WPF浏览器应用程序。现在的问题是,我要在beginig加载一些重服务,这会导致看到一个白色的页面,几秒钟得到加载的页面组件之前。是否有办法避免这种通过某种方式,而不必等待重进程完成加载页面?
I am working on a WPF Browser Application. The problem is that I have to load some heavy services in the beginig, this causes to see a white page for some seconds before the page components get loaded. Is there a way to avoid this somehow by loading the page without waiting for the heavy processes to finish?
下面是现在的事,我想,它没有工作:
Here is the thing I am trying now, and it didn't work:
public Page1()
{
InitializeComponent();
}
private void Page_Loaded_1(object sender, RoutedEventArgs e)
{
// Initialize and configure kinect
// This takes some seconds
}
我的想法后,页面的所有组件已完成加载的page_loaded事件发生。但它仍然等待进程完成,我在开始时获得一个白色的页面的某些秒......
I was thinking the page_loaded event happens after all the components of the page have finished loading. But still it waits for the processes to finish and I get some seconds of a white page in the begining...
您可以使用BackgroundWorkers来处理长期运行的操作。这将保持用户界面响应,而任务(S)正在运行。去这里了解更多:的http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx
You can use BackgroundWorkers to handle the long-running operations. This will keep the UI responsive while the task(s) are running. Go here to learn more: http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx