How to write program in Silverlight that would do something every 10 seconds, eg, process twitter search results? The closest I came up is this:
// Get and process new twitter search results evey 10 seconds
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (sender, args) =>
{
while (true)
{
//Get results of Twitter Search and process them in the above code
client.DownloadStringAsync(new Uri("http://search.twitter.com/search.json?q=" + keywords + "&show-user=true", UriKind.Absolute));
// wait 10 seconds beofre getting new twits
System.Threading.Thread.Sleep(10000);
}
};
worker.RunWorkerAsync();
but it not work. plz help.
If you want the code to be excuted on the UI thread, you need
DispatcherTimer. See this post.