I have built a small game application (simple keno game) that runs fine as long as my form has focus. But when the form loses focus, the application stops responding, and does not resume properly when you click back on it. The game continues to run, but the form events are no longer drawn (I hope that is the right term). The only reason I know the code is still running is that the .wav sound files keep playing (no background loops running).
I would give a code sample, but I don't really know what I should include. The code is about 3500 lines in the form, so I guess what I'm wondering is if there is some method of getting the application to continue to process the visible events, even though it doesn't have focus
(This game is self-contained, and does not communicate with any outside resources.)

VB2005 (express) Application Stops Responding
Timothy Downs
By the way, should the randomize command be used each time or just at the form load )
It only needs to be called once.
Try this....
Just before you sleeps.... try putting an application.Doevents() in.
If there are places in the the code that you can specifically identify , when you know you need a refresh/screen painting call a DoEvents.
Ian Hopkins
does this code have any tight loops or places of very intense computation
Sregan
Thanks for the quick response!
Tight loops Yes, sort-of (I would call them loose though...
)
Intense computation Not really, mostly addition, subtraction, but these are just incrementer variables to determine the users credits, games remaining, etc. One multiplication routine, to make the user's winnings scale to their wager. The only other computation is the routine to generate 20 unique random numbers between 1 and 80. (By the way, should the randomize command be used each time or just at the form load )
The program does have some for ... next loops in it (No do...loops, or loop...until, or while loops). Heres the flow:
If the problem is due to the For ... Next Loops, how does one check to make sure the user interface is updating and and force it to be responsive within the loops
On further testing, the user interface comes back (not always) when the main for ... next loop (number of games) is finished, so if I can figure out how to refresh/or redraw the entire form within the for...next loops, even if the window does not have focus, it would probably solve most, if not all, of the problem.
Tiramisu
Beautiful! Thank you!
I was using the element.refresh() method. I had seen in an article that doevents() wasn't necessarily a good thing, so I didn't think to try it!
My last bug- Gotta figure out how to stop the code from running if someone clicks the forms close button. I'll go rtfm again ;)
I figured it out... Sometimes things are just too easy...
<code>
Private Sub form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
End
End Sub
</code>