简体   繁体   中英

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

I am trying to show a loading page in windows phone 8.1

I want to call function this.GetAllRings after i can see the layout. I have tried added in loaded but it still don't work. Unless the entire query is complete, i see black screen. How can i fix this

Following is my code

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();
    }

In your MainPage_Loaded method your request is probably blocking the UI thread. You should try the following:

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

This should do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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