Frage

I am implementing searching within my Metro application. The search works well, results and UI come up as expected with one problem though.

I try to display a ProgressRing before the search and hide it after the search completes, but it never gets displayed.

What am I missing, code snippet below:

    protected override void OnSearchActivated(Windows.ApplicationModel.Activation.SearchActivatedEventArgs args)
    {
        // Some Metro designer generated code here

        // Show progress ring
        MainPage.Current.ResetProgressRingState(true);

        // Bind search results
        MainPage.Current.BindSearchResults(args.QueryText);

        // Ensure the current window is active
        Window.Current.Activate();

        // Hide progress ring
        MainPage.Current.ResetProgressRingState(false);
    }

I suspect that the BindSearchResults method needs to be awaited in order for the ProgressRing to work correctly. If so, what's the easiest way to make that method awaitable, if not please advise what I am missing here.

War es hilfreich?

Lösung

If so, what's the easiest way to make that method awaitable, if not please advise what I am missing here.

Mark it as async and have it return Task. Within that method, use await on other asynchronous operations.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top