Home All Groups Group Topic Archive Search About

Imposing a delay in code execution

Author
1 Apr 2005 6:59 PM
Marty
Hi,

Is there a "light" way on CPU usage to delay a process in the code
execution.  For example, if I want a function to wait 5 seconds before
continue executing without using a timer.

Is there a better way than using this:
While (MyCondition is true)
    System.Windows.Forms.Application.DoEvents()
End While

Thanks,
Marty

Author
1 Apr 2005 7:02 PM
Marina
Use the Thread.Sleep method.

"Marty" <xmart***@hotmail.com> wrote in message
news:FSg3e.107325$KI2.52988@clgrps12...
Show quoteHide quote
> Hi,
>
> Is there a "light" way on CPU usage to delay a process in the code
> execution.  For example, if I want a function to wait 5 seconds before
> continue executing without using a timer.
>
> Is there a better way than using this:
> While (MyCondition is true)
> System.Windows.Forms.Application.DoEvents()
> End While
>
> Thanks,
> Marty
Author
1 Apr 2005 7:45 PM
Marty
Great,
that's really nice :)
Marty



Marina wrote:

Show quoteHide quote
> Use the Thread.Sleep method.
>
> "Marty" <xmart***@hotmail.com> wrote in message
> news:FSg3e.107325$KI2.52988@clgrps12...
>
>>Hi,
>>
>>Is there a "light" way on CPU usage to delay a process in the code
>>execution.  For example, if I want a function to wait 5 seconds before
>>continue executing without using a timer.
>>
>>Is there a better way than using this:
>>While (MyCondition is true)
>>System.Windows.Forms.Application.DoEvents()
>>End While
>>
>>Thanks,
>>Marty
>
>
>
Author
1 Apr 2005 7:32 PM
Herfried K. Wagner [MVP]
"Marty" <xmart***@hotmail.com> schrieb:
> Is there a "light" way on CPU usage to delay a process in the code
> execution.  For example, if I want a function to wait 5 seconds before
> continue executing without using a timer.
>
> Is there a better way than using this:
> While (MyCondition is true)
> System.Windows.Forms.Application.DoEvents()
> End While

'System.Threading.Thread.Sleep(<number of milliseconds>)' will block the
currently executing thread.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>