Home > Software design >  Make button appears after 5 seconds forever in C#
Make button appears after 5 seconds forever in C#

Time:09-16

In my Xamarin app, there is a button, which I want to make visible after 5 seconds.

I tried Device.StartTimer, but it make button appears after 5 seconds, and then after 5 seconds later hide it and then after 5 seconds make it appears again (forever).

Device.StartTimer(TimeSpan.FromSeconds(5), () =>
{
    // Button

    return true;
});

How can I make button appears after 5 seconds, and it never disappears?

CodePudding user response:

I think what you need is to return false so the Timer only runs once.

I.e.:

Device.StartTimer(TimeSpan.FromSeconds(5), () =>
{
    /* Make your button appears here */
    // ...
    return false;
});

CodePudding user response:

you can also use the Thread.sleep(5000); method instead in c# code. that hold your thread for 5 seconds, then that button will shows up on screen.

  • Related