Should I thread this?
- by Psytronic
I've got a "Loading Progress" WPF form which I instantiate when I start loading some results into my Main Window, and every time a result is loaded I want the progress bar to fill up by x amount (Based on the amount of results I'm loading).
However what happens is that the Progress bar in the window stays blank the entire time, until the results have finished loading, then it will just display the full progress bar.
Does this need threading to work properly? Or is it just to do with the way I'm trying to get it to work?
//code snippet
LoadingProgress lp = new LoadingProgress(feedCount);
lp.Show();
foreach (FeedConfigGroup feed in _Feeds) {
feed.insertFeeds(lp);
}
//part of insertFeeds(LoadingProgress lbBox)
foreach (Feeds fd in _FeedSource) {
lpBox.setText(fd.getName);
XmlDocument feedResults = new XmlDocument();
feedResults.PreserveWhitespace = false;
try {
feedResults.Load(wc.OpenRead(fd.getURL));
} catch (WebException) {
lpBox.addError(fd.getName);
}
foreach (XmlNode item in feedResults.SelectNodes("/rss/channel/item")) {
//code for processing the nodes...
}
lpBox.progressIncrease();
}
If more code is needed let me know.