I have this backgroundworker:
MyBackgroundWorker.DoWork += ((sender, arg) =>
{
while (true)
{
client.GetkFailuresCompleted += ((s, e) =>
{
int[] arr = JsonHelper.Deserialize<int[]>(e.Result);
int error = (int)((arr[0] / (double)arr[1]) * 100);
Debug.WriteLine("Error %: " + error);
this.Dispatcher.BeginInvoke(() =>
{
ErrorOverviewPointCollection.Clear();
ErrorOverviewPointCollection.Add(new Point(1, 100 - error));
ErrorOverviewPointCollection.Add(new Point(1, error));
});
});
client.GetFailuresAsync();
Thread.Sleep(5000);
}
});
And as you see Im running it forever. I'm not implementing any stop/fail functions to stop the BackgroundWorker
, but do I need to? If the user closes the browser the application should stop right?
The DoWork
accesses a webservice that on completion updates a ObservableCollection
that is databound to the silverlight application.