繁体   English   中英

在添加布局并完整显示后加载功能

[英]Load a function after the layout is being added and shown completely

我正在尝试在Windows Phone 8.1中显示加载页面

我想在看到布局后调用函数this.GetAllRings 我曾尝试在加载中添加内容,但仍然无法正常工作。 除非整个查询完成,否则我会看到黑屏。 我怎样才能解决这个问题

以下是我的代码

public MainPage()
    {
        this.InitializeComponent();
        this.app = App.Current as App;
        this.Loaded += MainPage_Loaded;

        this.NavigationCacheMode = NavigationCacheMode.Disabled;
    }

    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {            
        this.GetAllRings();
    }

在MainPage_Loaded方法中,您的请求可能会阻止UI线程。 您应该尝试以下方法:

await Task.Run(() => this.GetAllRings());

这应该做。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM