Board index » Visual Studio » VB application appears to be hanging, help...

VB application appears to be hanging, help...

Visual Studio287
In my VB application whenever I am doing an operation that needs to

loop for a long period of time, such as loading a large table from the

database, my program appears to just be hanging eventhough it isn't.

The application loses focus, the window stops redrawing itself and the

title bar says "Not Responding" until the operation is complete. This

has become a problem because a lot of users of my application think it

hung eventhough it's just taking a while to load. How can I fix this

so that the program doesn't appear to be hanging while a loading

process is occurring?


-
 

Re:VB application appears to be hanging, help...

Hi Ray,



You must yield processing to the message pump (managed by VB) from

time to time.



For a long process controlled by your app, try adding a DoEvents that

gets executed every second, or whatever makes sense for your app. For

a long running stored proc, Execute Command objects asynchronously.



Be aware that these approaches require a little more care about how

state is managed. For instance, that DoEvents could be all the user

needs to click the Close button (or Window "X") on your application

and pull the rug out from underneath you.



Hope this helps.



--

+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+

Monte Hansen - MVP VB

KillerVB.com">KillerVB.com

+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+



"Ray Lavelle" <bostonpartykid@yahoo.com>wrote in message

Quote
In my VB application whenever I am doing an operation that needs to

loop for a long period of time, such as loading a large table from

the

database, my program appears to just be hanging eventhough it isn't.

The application loses focus, the window stops redrawing itself and

the

title bar says "Not Responding" until the operation is complete.

This

has become a problem because a lot of users of my application think

it

hung eventhough it's just taking a while to load. How can I fix

this

so that the program doesn't appear to be hanging while a loading

process is occurring?



-