Link to home
Start Free TrialLog in
Avatar of beaconlightboy
beaconlightboy

asked on

VB.net app screen does not refresh

i wrote and application which that reads thru my server event logs.  the log files can be large and i have a progress bar on a statusbar.

the text in the status bar will update itself when told to, for instance ["now reading record ## of ##"]  but the statusbar will not increment.  even when i force a refresh of it.  also, when i minimize the app, and then bring it backup, the statusbar text refuses to even update anymore.

how do i fix this?
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Sounds like you have a "tight loop" that is processing your logs.  Because of this your app is unable to process its messages and updates its interface since it is stuck in the loop.

The simple solution is to add this line:

    Application.DoEvents()

inside your loop to allow your app to process its messages and update accordingly.

The "correct" solution though would be to move your processing into another thread so that your main UI interface does not get locked up.   This is more complex though is you need to use Delegates to marshal the call from your thread back onto the main UI thread.  Let me know if you want to go that route...
Avatar of beaconlightboy
beaconlightboy

ASKER

i was researching threads, but wasnt sure how to update the gui when using one.  when i set on up it just ran the code and said it was done, even though i know it wasnt.
So you need a simple example of how to set up a thread and update the main GUI from it?
that would be great.  
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial