In my Xamarin.Forms application, I have code that opens a popup page (using the Rg Popups plugin) which executes a call to my API that inserts some data on the database.
I need the async call for the popup to open to wait until the popup page's task finishes then execute another async call which updates a ListView in the current view.

However, the popup's async task does not wait until the popup has finished working to continue to the next task, which means the view isn't updated

Here's the code in question:

```
 bool jobTask = await CloseCurOpenJob();

if (jobTask == true)
{
  await FillDocuments();
}

```

```
 await Navigation.PushPopupAsync(new JobClosePopupPage(Base.activeJobId));
 return true;

```

```
private async Task<string> FillDocuments()
        {
HttpClient client = new HttpClient();
            try
            {
                if (jobid > 0)
                {
                    var response = await client.GetStringAsync(myApiUri);
                    var DocumentsList = JsonConvert.DeserializeObject<List<DocumentHeader>>(response);
                    Documents = new ObservableCollection<DocumentHeader>((IEnumerable<DocumentHeader>)DocumentsList);

                    DocumentCount = Documents.Count();
                    DocumentSubtotal = Documents.Sum(instance => instance.TotalQuantity);
                }

                return "OK";
            }
            catch (Exception e)
            {
                return e.Message;
            }
}

```

And here's the code in the popup page's ViewModel

```
private async Task<bool> CloseJob(int jobid)
        {
            HttpClient client = new HttpClient();
            try
            {
                var response = await client.PostAsync(myAPIUri);
                string responseString = await response.Content.ReadAsStringAsync();
                if (response.IsSuccessStatusCode)
                {
                    await CheckGetOpenJob();
                    return true;
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert(Base.applicationTitle, responseString, "OK");
                    return false;
                }

            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert(Base.applicationTitle, e.Message, "OK");
                return false;
            }
            finally
            {
                await Navigation.PopPopupAsync();

            }
        }

```

I have tried using Task.Run and Task.Delay but the result is still the same - the FillDocuments method runs after the popup has been shown, not after it has been dismissed.