AlertDialog doesn't show at .show()

I have the following code:

private void CloseOrder(object sender, EventArgs e)
        {
            Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(this);

            alert.SetTitle("Cerrar Pedido");
            alert.SetMessage("Are you sure?");
            alert.SetCancelable(true);
            alert.SetPositiveButton("Confirm", delegate { this.Rta = true; });
            alert.SetNegativeButton("Cancel", delegate { this.Rta = false; });
            Dialog dialog = alert.Create();
            dialog.Show();

            if (this.Rta)
            {
                //Some code here
            }

        }

this.Rta is a property of my class.

The problem is that the alert doesn't show at "dialog.show()", it shows once the method "CloseOrder()" ended, so this.Rta never gets the corresponding value assigned.

I've been searching a lot but I can't find a solution, if anyone can help me that'd be great!

Answers

Sign In or Register to comment.