TextBox vs. Label vs. StatusBar with displaying updates to user

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a database processing code that occurs and during the loop of SqlCommands I execute I am displaying a progress bar. I also wanted to get updates what step exactly the progress bar was on
I added a label control and updated the text property of the control with the "title" of the step. When this loops it doesn't work and the text gets updated at the end of the loop (with the last step by passing the previous ones). So I tried a textbox control and that didn't work either. So then I tried a statusbar control and that worked fine...updating the text as the progress went ahead!!
Am I missing something or is there another way to do this ( i.e. another thread, callback delegate). Because it seems that .NET is posponing this update at a later time.
 
Homer
What I have found is if you are in a processing loop & try to update a visual control it might take a while to see changes. I have inserted into my processing loop : Application.DoEvents(); (C#) In simplistic terms, this method processes all the waiting messages, ie. a control repaint because of setting text in a control

Hope this helps

----- Homer wrote: ----

I have a database processing code that occurs and during the loop of SqlCommands I execute I am displaying a progress bar. I also wanted to get updates what step exactly the progress bar was on
I added a label control and updated the text property of the control with the "title" of the step. When this loops it doesn't work and the text gets updated at the end of the loop (with the last step by passing the previous ones). So I tried a textbox control and that didn't work either. So then I tried a statusbar control and that worked fine...updating the text as the progress went ahead!!
Am I missing something or is there another way to do this ( i.e. another thread, callback delegate). Because it seems that .NET is posponing this update at a later time.
 
* "=?Utf-8?B?SG9tZXI=?= said:
I have a database processing code that occurs and during the loop of SqlCommands I execute I am displaying a progress bar. I also wanted to get updates what step exactly the progress bar was on.
I added a label control and updated the text property of the control with the "title" of the step. When this loops it doesn't work and the text gets updated at the end of the loop (with the last step by passing the previous ones). So I tried a textbox control and that didn't work either. So then I tried a statusbar control and that worked fine...updating the text as the progress went ahead!!!

Call the control's 'Refresh' method directly after setting its text.
 
Homer,

You're not seing the updates because the control only get's painted after
you actually exit your loop...... Anyway you might want to increase the
responsiveness while working in your loop and maybe you even want to give
the use a chnace to cancel the operation.

Use a worker thread then if you know how to use this technique or use the
Application.DoEvents when you don't really know about worker threads and the
synchronisations required.

regards

Chris

Homer said:
I have a database processing code that occurs and during the loop of
SqlCommands I execute I am displaying a progress bar. I also wanted to get
updates what step exactly the progress bar was on.
I added a label control and updated the text property of the control
with the "title" of the step. When this loops it doesn't work and the text
gets updated at the end of the loop (with the last step by passing the
previous ones). So I tried a textbox control and that didn't work either.
So then I tried a statusbar control and that worked fine...updating the text
as the progress went ahead!!!
Am I missing something or is there another way to do this ( i.e. another
thread, callback delegate). Because it seems that .NET is posponing this
update at a later time.
 
Back
Top