none
task pane Apps For Office how do wait for asynchronous call to finish before calling next asynchronous call in a loop ? RRS feed

  • Question

  • task pane Apps For Office how do wait for asynchronous call to finish before calling next asynchronous call in a loop ?

    Ahsan Ranjha

    • Moved by Qiao Wei Tuesday, April 1, 2014 9:20 AM app for office question
    Monday, March 31, 2014 2:45 PM

Answers

  • Hi Ahsan,

    You could call the next asynchronous function in callback function of the previous asynchronous function.

    For example, here is an asynchronous function as below which is from How to: Create your first content app for Excel by using "Napa" Office 365 Development Tools:

    function getTextFromDocument() {
        Office.context.document.getSelectedDataAsync(Office.CoercionType.Text,
            { valueFormat: "unformatted", filterType: "all" },
            function (asyncResult) {
                showStockData(asyncResult.value);
            });
    }
    

    You could call another asynchronous function in:

    function (asyncResult) {
    });
    

    In this case, the next asynchronous function would be executed while the previous asynchronous function finished.

    Hope this helps.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 2, 2014 10:02 AM
    Moderator