wait or sleep 
Author Message
 wait or sleep

I want that my App wait N seconds and then continue

Example

Private sub test()
    msgbox "msgbox1"
    wait 1000     'milliseconds
    msgbox "msgbox2"
end sub

But my problem is that when use the  Thread.Sleep my app stop all (freeze),
I dont't like this.

Microsft was posted a code for VB6 called wait function. It work perfect (in
vb6).

Thanks.



Sun, 12 Dec 2004 22:49:41 GMT  
 wait or sleep

Quote:
> I want that my App wait N seconds and then continue

> Example

> Private sub test()
>     msgbox "msgbox1"
>     wait 1000     'milliseconds
>     msgbox "msgbox2"
> end sub

> But my problem is that when use the  Thread.Sleep my app stop
> all (freeze), I dont't like this.

> Microsft was posted a code for VB6 called wait function. It work
> perfect (in vb6).

> Thanks.

Why not use a timer (from components tab in toolbox)?

Armin



Sun, 12 Dec 2004 23:04:07 GMT  
 wait or sleep
I need to preserve the sequence, I need just sleep the function for a while
and then resume.

Thanks.


Quote:

> > I want that my App wait N seconds and then continue

> > Example

> > Private sub test()
> >     msgbox "msgbox1"
> >     wait 1000     'milliseconds
> >     msgbox "msgbox2"
> > end sub

> > But my problem is that when use the  Thread.Sleep my app stop
> > all (freeze), I dont't like this.

> > Microsft was posted a code for VB6 called wait function. It work
> > perfect (in vb6).

> > Thanks.

> Why not use a timer (from components tab in toolbox)?

> Armin



Sun, 12 Dec 2004 23:36:59 GMT  
 wait or sleep
I used to use a function like :

Start = timer
do while timer < start + 50
    doevents
loop

If I was monitoring a directory forexample for new files to arrive there was
a huge problem in this.
The problem with this is the system resources. Take a look at the processing
overhead - you application will jump up to 99% processing resources. OUCH!
Using a timer and then it's method to search for files eliminated that
problem - it uses a call to the CPU which does not such up processing
resources - I guess the CPU sends notification back to the thread with the
callback and away it goes - so crazy loop.
But that doesn't help for just pausing a few seconds.... not gracefully
right?
So can someone post a good delay function that does not affect the system
resources like the loop above does?


Quote:

> > I want that my App wait N seconds and then continue

> > Example

> > Private sub test()
> >     msgbox "msgbox1"
> >     wait 1000     'milliseconds
> >     msgbox "msgbox2"
> > end sub

> > But my problem is that when use the  Thread.Sleep my app stop
> > all (freeze), I dont't like this.

> > Microsft was posted a code for VB6 called wait function. It work
> > perfect (in vb6).

> > Thanks.

> Why not use a timer (from components tab in toolbox)?

> Armin

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.362 / Virus Database: 199 - Release Date: 05/07/2002


Sun, 12 Dec 2004 23:42:43 GMT  
 wait or sleep
 Dim oNow As Date = DateTime.Now
  Do
   Application.DoEvents()
  Loop Until DateTime.Now >= oNow.AddMilliseconds(3000)

HTH
Corrado



Sun, 12 Dec 2004 23:54:56 GMT  
 wait or sleep

Quote:

> I used to use a function like :

> Start = timer
> do while timer < start + 50
>     doevents
> loop

> If I was monitoring a directory forexample for new files to arrive there was
> a huge problem in this.
> The problem with this is the system resources. Take a look at the processing
> overhead - you application will jump up to 99% processing resources. OUCH!

Why don't you use the FileSystemWatcher?

Marc



Mon, 13 Dec 2004 00:22:04 GMT  
 wait or sleep

Quote:
> I used to use a function like :

> Start = timer
> do while timer < start + 50
>     doevents
> loop

> If I was monitoring a directory forexample for new files to
> arrive there was a huge problem in this.
> The problem with this is the system resources. Take a look at
> the processing overhead - you application will jump up to 99%
> processing resources. OUCH! Using a timer and then it's method
> to search for files eliminated that problem - it uses a call to
> the CPU which does not such up processing resources - I guess
> the CPU sends notification back to the thread with the callback
> and away it goes - so crazy loop. But that doesn't help for just
> pausing a few seconds.... not gracefully right?
> So can someone post a good delay function that does not affect
> the system resources like the loop above does?

I don't understand the problem: Do you want to be able to interact with your
application or not? If yes, a timer does a good job. If you don't want
interaction, you can disable the form (.enabled = false). As I don't
consider it to be a good UI behavior you can display a form modally that
does nothing but displaying "Please wait...".

You still can use Threading.Thread.Sleep(10000) that waits 10 seconds
without CPU utilization.

Armin



Mon, 13 Dec 2004 00:28:55 GMT  
 wait or sleep

Quote:
> I need to preserve the sequence, I need just sleep the function
> for a while and then resume.

If you enable the timer after the first messagebox, don't you preserve the
sequence?

Armin



Mon, 13 Dec 2004 00:17:49 GMT  
 wait or sleep
The problem is my ignorance. ;-)
I was unaware of both

Threading.Thread.Sleep(10000)
 - and -
FileSystemWatcher

Are these exclusive to .NEt or available to VB6 as well?


Quote:
> I used to use a function like :

> Start = timer
> do while timer < start + 50
>     doevents
> loop

> If I was monitoring a directory forexample for new files to arrive there
was
> a huge problem in this.
> The problem with this is the system resources. Take a look at the
processing
> overhead - you application will jump up to 99% processing resources. OUCH!
> Using a timer and then it's method to search for files eliminated that
> problem - it uses a call to the CPU which does not such up processing
> resources - I guess the CPU sends notification back to the thread with the
> callback and away it goes - so crazy loop.
> But that doesn't help for just pausing a few seconds.... not gracefully
> right?
> So can someone post a good delay function that does not affect the system
> resources like the loop above does?




> > > I want that my App wait N seconds and then continue

> > > Example

> > > Private sub test()
> > >     msgbox "msgbox1"
> > >     wait 1000     'milliseconds
> > >     msgbox "msgbox2"
> > > end sub

> > > But my problem is that when use the  Thread.Sleep my app stop
> > > all (freeze), I dont't like this.

> > > Microsft was posted a code for VB6 called wait function. It work
> > > perfect (in vb6).

> > > Thanks.

> > Why not use a timer (from components tab in toolbox)?

> > Armin

> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.362 / Virus Database: 199 - Release Date: 05/07/2002

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.362 / Virus Database: 199 - Release Date: 05/07/2002


Mon, 13 Dec 2004 00:36:08 GMT  
 wait or sleep
I just need to make a pause.

Example

I wait for a flag

While Flag = False
    wait 10 'milliseconds
Wend

The flag can be anithing

Thanks again
    Anibal Acosta.


Quote:

> > I used to use a function like :

> > Start = timer
> > do while timer < start + 50
> >     doevents
> > loop

> > If I was monitoring a directory forexample for new files to
> > arrive there was a huge problem in this.
> > The problem with this is the system resources. Take a look at
> > the processing overhead - you application will jump up to 99%
> > processing resources. OUCH! Using a timer and then it's method
> > to search for files eliminated that problem - it uses a call to
> > the CPU which does not such up processing resources - I guess
> > the CPU sends notification back to the thread with the callback
> > and away it goes - so crazy loop. But that doesn't help for just
> > pausing a few seconds.... not gracefully right?
> > So can someone post a good delay function that does not affect
> > the system resources like the loop above does?

> I don't understand the problem: Do you want to be able to interact with
your
> application or not? If yes, a timer does a good job. If you don't want
> interaction, you can disable the form (.enabled = false). As I don't
> consider it to be a good UI behavior you can display a form modally that
> does nothing but displaying "Please wait...".

> You still can use Threading.Thread.Sleep(10000) that waits 10 seconds
> without CPU utilization.

> Armin



Mon, 13 Dec 2004 02:37:15 GMT  
 wait or sleep

Quote:
> I just need to make a pause.

> Example

> I wait for a flag

> While Flag = False
>     wait 10 'milliseconds
> Wend

> The flag can be anithing

> > You still can use Threading.Thread.Sleep(10000) that waits 10 seconds
> > without CPU utilization.

Armin


Mon, 13 Dec 2004 05:26:08 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. HOW to wait or sleep to free CPU time

2. Pause, Delay, Wait, or Sleep Function

3. Wait or Sleep command

4. WAIT or SLEEP

5. Wait or Sleep command

6. Wait/sleep/pause function

7. Sleep / Wait function ??

8. Waiting: sleeping?

9. BEEP and WAIT/SLEEP in IE5.5

10. Sleep - timeout - wait

11. best way to sleep or wait specified amount of time

12. sleep/wait/delay

 

 
Powered by phpBB® Forum Software