Stavrogin
Stavrogin

Reputation: 143

Make button appears after 5 seconds forever in C#

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?

Upvotes: 0

Views: 445

Answers (2)

Vitor P. Carneiro
Vitor P. Carneiro

Reputation: 56

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;
});

Upvotes: 3

Rizwan
Rizwan

Reputation: 130

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.

Upvotes: -1

Related Questions