[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 439
  • Last Modified:

Label Text does not get updated

I am trying to set the text of a label control based on a condition in a loop.

The condition is reached about 10 times during the loop.

The final text value is ->->->->->->->->->->->->->->

The label acts as a progress bar.

There is no error, but the label text does not get updated.

string strProgressChar = "->";
   
      for (int i = 0; i <=8000 ; i++)
       {
                intProgress++;
               
                if (intProgress == intProgressIncrement)  // increment is 300
                {
                    lblProgress.Text = lblProgress.Text + strProgressChar;  // Text is not updated
                    intProgress = 0;
                }

        }  // End  while ((line = sr.ReadLine()) != null)


Any help would be appreciated.

Thanks,
0
Dovberman
Asked:
Dovberman
  • 3
  • 2
  • 2
  • +2
1 Solution
 
Tom BeckCommented:
I'm not going to be much help here because I don't have access to VS for testing. When update bars do not show progress it's almost always because the processing thread you are attempting to report on is busy so it cannot also update the progress. In other words, it cannot do two things at once. You need to introduce a pause/update/resume logic at short intervals in your coding for the main process or add a second processing thread for the update (Google multi-threaded operations for asp.net) or you could do a progress bar using ajax for polling. Look here.You may need to provide the main process code to get the help you need.

That's my entire contribution to this question.
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
You can't do it like this in asp.net

in ASP.Net when you're running that process the entire thing is server side, the page doesn't reload again until after all of the server side code is finished running.

If you wanted to use the label as a progress bar you would need a web service of some kind.

See below for more information:
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_28283009.html
0
 
DovbermanAuthor Commented:
I thought I would need a delay step.  I will try the timer and provide feedback.

Thanks,
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
DiscGolfDadCommented:
You can try either the .Refresh method of the label control, or you could invoke whatever your language's equivalent of "DoEvents" is.  I have to use DoEvents in VB programming, but overuse can be a problem, that's why I only use it at certain intervals using the MOD function, i.e. If intRec MOD 100 = 0 Then DoEvents
0
 
DovbermanAuthor Commented:
There is no .Refresh method for a label control.
0
 
DiscGolfDadCommented:
Then instead try the Refresh method of the form.
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
If this is for asp.net there is no .refresh on the form.
0
 
johny_bravo1Commented:
Well Asp.Net gives you more option for display a progress bar rather than using label.

If you are using UpdatePanel use UpdateProgress control.

Alternatively you can use javascript/ jquery, check below links for javascript

http://www.javascriptkit.com/script/script2/progressbar.shtml

http://jqueryui.com/progressbar/#default
0
 
DovbermanAuthor Commented:
Thank you
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now