Programatically dialing phone numbers in a loop with user input between each call

I'm developing a mobile app that "auto dials" phone numbers one by one from a list, while getting user input immediately after each phone call ends. Would anyone know how to "pause" the loop so the user can input details BEFORE the next phone number is dialed?

The Xamarin Forms code below triggers a phone call, pushes the user input modal, then loops without waiting for the user input (the opposite of what I want).

Autodial:
public void autoDial(string playlist){ foreach(ContactData c in App.Database.GetItems (playlist)){ call (c); } }

Call:
public async Task<bool> call(ContactData person){ var dialer = DependencyService.Get<IDialer> (); if (dialer != null) { if (await dialer.Dial (person.Number)) { person.Called = DateTime.Now; App.Database.UpdateItem (person); Navigation.PushModalAsync (new DatePage (Values.APPOINTED, person)); } } return false; }

Event Handler in ContentPage DatePage that takes care of the user input:
datePicker.DateSelected += (dateSender, de) => { //handle user input this.Navigation.PopModalAsync(); };

Answers

  • Amar_BaitAmar_Bait DZMember ✭✭✭✭✭

    If you want to pause by a certain amount of time you can:

    await Task.Delay(5000); // 5 seconds
    
  • christanchristan USMember

    Hi Nad, thanks for the reply! Yes that would work. Ideally, I'm looking for a solution that waits until the user inputs some value into my DatePage Modal then continues with the next iteration of the loop. Sorry I may have been a little vague on that part

Sign In or Register to comment.