Muhammad Umar
Muhammad Umar

Reputation: 11782

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

Upvotes: 1

Views: 42

Answers (1)

meneses.pt
meneses.pt

Reputation: 2616

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.

Upvotes: 1

Related Questions