Search code examples
vb6time-wait

sleep without freezing gui vb6


I need to wait for some events in my application, or wait for somew time to elaps before doing some other stuff

i tried this pseudo code in vb6

starttime=gettickcount
do
endtime=gettickcount
if endtime-starttime=>waittime then exit do
doevents()
loop

But this seems to freezes the gui, i need an alternative method that will wait without freez the gui

EDIT i forgot the doevents, please take note


Solution

  • I suggest using a timer. A timer fire off an event whenever it reaches it's tick count. So you could tell something to fire every 3 seconds, 3 minutes, 1 hour, etc.

    The timer will run in the background allowing your app to continue functioning as normal while it counts down.