Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Status strip update 1

Status
Not open for further replies.

hondaman2003

Programmer
Mar 3, 2008
202
US
This is really silly so I apologize in advance. I would like to update the text in a status strip. I do not get any errors but while the application is running, the text in the status strip doesn’t change. When I insert a messagebox command after the status strip command it will show the message I want to display like this

lblToolStrip.Text = "Loading, Please Wait..."
MessageBox.Show (lblToolStrip.Text)

That will show the correct text but if I do not have that message box command in there, it’s like the program doesn’t stop to change the text till it’s ready again like this

lblToolStrip.Text = "Ready"

I’m sure this is very easy but I just don’t know how to make it show the “Loading, please wait…”
 
Try

Application.DoEvents()

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
Be advised, DoEvents is not always the best approach. While in a hard loop, it can dramatically slow down processing. There are some other issues with threading and cancelling that can cause "Object Undefined", etc errors. Be sure to read up on it before using it freely.

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
Thank you for the heads up. I am simply going to use it only after updating the status strip with NEVER happens in a loop. That shouldn't be a problem right?
 
You should be fine then. What the DoEvents does (in a very brief description) is tells the system to process everything that is pending in the stack. Updates to paint a status strip with a new string would be in that stack. Pending requests from other applications will also be in that stack. That is why placing it in a loop can cause major slowdowns.

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
I completely understand now and sort of have a concept of why it would be a problem in a loop. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top