Forum Xamarin Xamarin.Android

How to ask user during processing data?

DenisMishinDenisMishin Member ✭✭
edited April 2019 in Xamarin.Android

Hi guys.
I have a method which is processing data. During execution the data can be processed several ways (new data or not and if new save it or decline new data etc). And every step is have to be managed by user and user have to decide how to process data.
So i have to ask user and wait his answer. Then, based on user choice continue to process data.
I'm using AlertDialog.

Shall i put data processing in other Task and stop this task for prompting user and resume after dialog result?
Or there is any other better way?

Very appretiate of your help.


  • JarvanJarvan Member, Xamarin Team Xamurai
    edited April 2019

    Try to use async-await to ensure the data is processed only after the user has made a selection. And you can add AlertDialog to prompt the user when processing is complete.

  • DenisMishinDenisMishin Member ✭✭

    @yelinzh the main goal is to make several question dialogs during processing. Not only before and at the end of processing data but in the middle too.
    Either to use Thread.Sleep at processing method until user click button at dialog or split processing method at logic steps and show dialog to user before every step step.

    how mutch is bad?

    bool isDetermined = false;
    AskUserToChoose(()=> { isDetermined = true; });
    while (!isDetermined)

    AskUserToChoose(Action callback) method shows AlertDialog and calls callback after user choice

  • JarvanJarvan Member, Xamarin Team Xamurai

    You can use Thread.Sleep() or Nested await.

Sign In or Register to comment.