Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How ACR UserDialog works when we have Task.Delay

NavinSamuelNavinSamuel USMember ✭✭
edited November 2020 in Xamarin.Forms

UserDialog is working if I run the command event async and having await Task.Delay(1000) before doing the complex functionalities i.e.

TappedCommand = new Command(async (object sender) =>
using(UserDialogs.Instance.Loading("Please Wait...")
 await Task.Delay(1000);
//Do some task and update UI // This might take 2-10 seconds based on the data

Note : The dialog box does not show if we remove "await Task.Delay(1000);"
Please let me know how the dialog box works when we await Task.Delay(1000) ? (Please explain what is happening in the above scenario)
Is it ok to use the above code syntax for showing user dialogs?

**Note **: The command event do complex functionalities and updates UI in between the complex functionalities .
I can't run the complex functionalities in separate task and run UI updation in BeginInvokeMainThread as already the code is more complex (more UI updation and task in between UI updation.


Sign In or Register to comment.