Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run code after a delay in Xamarin Android

I'm trying to show some code after a delay in my Android app.
The Java code for doing this is something like this:

new Handler().postDelayed(new Runnable()
{
   @Override
   public void run()
   {
     // your code that you want to delay here
   }
}, 1000/* 1000ms = 1sec delay */);

How do I do this in Xamarin.Android with C#?

like image 978
amitairos Avatar asked Aug 28 '16 07:08

amitairos


Video Answer


1 Answers

You can try this:

Handler h = new Handler();
Action myAction = () => 
{
    // your code that you want to delay here
};

h.PostDelayed(myAction, 1000);

Take a look at document

like image 93
ductran Avatar answered Sep 26 '22 01:09

ductran