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:
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?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++;
}