如何显示一个WPF页或窗口,而无需等待重过程完成 [英] How to display a WPF page or window without waiting for heavy processes to finish

查看:721
本文介绍了如何显示一个WPF页或窗口,而无需等待重过程完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个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

这篇关于如何显示一个WPF页或窗口,而无需等待重过程完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆