creating a delay

C

ChrisB

Hello:

I was wondering if someone might have a recommendation for creating a delay
within the execution of a .dll.

Currently I am using an empty for/next loop and it takes about 1 billion
cycles seems to create a 1 second delay (I know, probably not a good idea).

I was considering thread.sleep() but don't want to create any unintentional
side effects. Would this be a good idea or are there better options?

Thanks!

Chris
 
V

Vijaye Raji

What other side effects do you think it might create?

Sleep is the recommended method of delay. Looping forever will choke the
CPU and starve other lower priority threads.

If you are waiting for something, use Synchronization.

-vJ
 
F

Frank Oquendo

ChrisB said:
Hello:

I was wondering if someone might have a recommendation for creating a
delay within the execution of a .dll.

What's the delay for?
I was considering thread.sleep() but don't want to create any
unintentional side effects. Would this be a good idea or are there
better options?

Unless you're modifying data within the thread, I don't see a problem.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
G

Greg Beech [MSFT]

Thread.Sleep() is great for this sort of thing - it's exactly what it is
designed for.

Greg

This posting is provided "AS IS"with no warranties, and confers no rights.
 
C

ChrisB

Thanks to everyone for the advice.

I am creating the delay for a test component so that information is written
to a database at specified intervals - sounds like thread.sleep() is the way
to go.

I'll give it a try . . .

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top