|
-
July 26th, 2007, 05:56 AM
#1
UI not updating
I'm having a problem with a program I'm trying to write in C#. I run a long loop of downloading a file and parsing it after you click a button, but the status bar doesn't change until the loop is totally completed. I also had a progress bar, which did update, and go across. If you want to see code, here it is:
Code:
void BtnClick(object sender, EventArgs e)
{
string url = tb.Text;
string sea = search.Text;
string [] lines = sea.Split('\n');
string searchurl = "";
int depth = track.Value * 10;
int queryloop=0;
int depthloop=0;
int pro=lines.Length * depth;
int procount=0;
double percent=0;
while(queryloop < lines.Length){
depthloop = 0;
while(depthloop < depth){
//create search query
searchurl="http://www.google.com/search?q="+
lines[queryloop]
+"&hl=en&safe=off&start="+
depthloop
+"&sa=N";
//create download object
WebClient Client = new WebClient();
//download file
Client.DownloadFile(searchurl, " in.txt");
depthloop++;
procount++;
percent=((double)procount/(double)pro)*100;
progress.Value=(int)percent;
statustext.Text="current url: "+searchurl;
}
queryloop++;
}
basicly what this program is going to do is help with website optimization. I work for a company that wants their page higher on google for many searches, so I'm automating the process of checking the site rank on a specific search by downloading all the files, which is the first 10 pages of results for X amount of search querys, then parsing them. (I haven't gotten to the parsing yet, as you can see in the code) So what happens is as of now, it downloads all the files, as this is happening, the progress bar goes across, but the 'statustext.Text' doesn't show up until the progress bar goes all the way across, which means it is finished anyway. So my question is, how do I make the text display before the loop is finished?
Similar Threads
-
By sb85 in forum AntiVirus Discussions
Replies: 6
Last Post: November 7th, 2003, 11:38 PM
-
By emPtYKnOw in forum Newbie Security Questions
Replies: 15
Last Post: January 2nd, 2003, 05:02 AM
-
By manpreet in forum Site Feedback/Questions/Suggestions
Replies: 35
Last Post: November 5th, 2002, 08:24 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|