locked
how to show progress ring till the async web service task end.

    Question

  • Hi ,

    Am using a web service to save my users input, so i have to show progress ring while the page is saving.

    Once the data got saved i have to make the progress ring visible false.

    Plz suggest me how i can achieve it.

    My web service call is like this:

    Service1Client service = new Service1Client();

    var responseAlters = service.method1Async(id);

    if(responseAlters.IsCompleted)

    {

    // making progress ring visibility false.

    }

    but it is always skipped because the async task not completed yet.

    Thanks in advance.

    Wednesday, April 23, 2014 4:48 AM

Answers

  • in store apps we have the async /await pattern with tasks.

    code is really easy:

    public async void LoadData()
            {
                try
                {
                    // make progress circle visible
                    Service1Client service = new Service1Client();
                    var responseAlters = await service.method1Async(id);
                }
                catch
                {
                    // handle exceptions
                }
                finally
                {
                    // hide progress loader
                }
            }

    in the method signature add async keyword; place await before the async method call


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    • Marked as answer by Gopinath 1990 Wednesday, April 23, 2014 9:48 AM
    Wednesday, April 23, 2014 8:45 AM

All replies

  • in store apps we have the async /await pattern with tasks.

    code is really easy:

    public async void LoadData()
            {
                try
                {
                    // make progress circle visible
                    Service1Client service = new Service1Client();
                    var responseAlters = await service.method1Async(id);
                }
                catch
                {
                    // handle exceptions
                }
                finally
                {
                    // hide progress loader
                }
            }

    in the method signature add async keyword; place await before the async method call


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    • Marked as answer by Gopinath 1990 Wednesday, April 23, 2014 9:48 AM
    Wednesday, April 23, 2014 8:45 AM
  • thanks smits.

    Wednesday, April 23, 2014 9:48 AM