Alexandr Sargsyan
Alexandr Sargsyan

Reputation: 724

Thread Sleeping in Xamarin Android with C#

I am trying to sleep my app for any milliseconds.

Developing simple app (just for fun) and I want that after my click works timer.

Thread.Sleep(8000); 

Don't worked

new CountdownTimer(30000,1000); 

not worked.

Is it so difficult?

Upvotes: 0

Views: 2337

Answers (1)

Kaelan Fouwels
Kaelan Fouwels

Reputation: 1185

You should be able to use:

 await Task.Delay(x);

With x being milliseconds. You will evidently also need to be an an Async method for awaiting to be valid:

public async void Method1()
{
    //etc. 
    await Task.Delay(x);
}

Upvotes: 1

Related Questions