Adam
Adam

Reputation: 291

Silverlight - fire of delayed action -

When I click on a button in Silverlight I want to run a method 2 seconds later once only for each time I click the button .. in the meantime the rest of the app keeps working .. obviously Thread.Sleep stops the whole UI .. how do I do this?

Upvotes: 2

Views: 122

Answers (1)

tchrikch
tchrikch

Reputation: 2468

Inside handler start a new thread that will wait 2 seconds and execute your method. I mean something like

public void button_click(...) 
{
  (new Thread( (new ThreadWorker).DoWork).Start();
}
public class ThreadWorker
{
  public void DoWork() { Thread.Sleep(2); RunMyCustomMethod();}
}

Upvotes: 2

Related Questions