A lot of times there is a requirement to introduce some delay before an action can be taken. We will see how can we introduce a pause in Silverlight.

void Wait()
{
BackgroundWorker worker = new BackgroundWorker();
worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
worker.DoWork += Worker_Sleep;
worker.RunWorkerAsync();
}

void Worker_Sleep(object sender, DoWorkEventArgs e)
{
Thread.Sleep(1000); // Sleep the background thread for 1 sec
}

void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{

// You can write code here for the action which is to be taken after the

// delay
}

How to introduce delay in Silverlight

Leave a Reply

Your email address will not be published. Required fields are marked *