Click here to Skip to main content
15,919,358 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
I'm trying to create a code with some millisecond delay time in loop routine.
I don't know how to do it. Please help me.

my code :

for (i=1;i<10;i++)
   int a=mycode(); // mycode is my function name, it will return the delay time

int mycode()

But delay time is not working?
Updated 14-Apr-11 19:40pm
Sunasara Imdadhusen 15-Apr-11 1:22am    
Added <pre> tag.
Sunasara Imdadhusen 15-Apr-11 1:23am    
Is there any error?
Saptur 15-Apr-11 1:28am    
Pong D. Panda 15-Apr-11 1:24am    
What do you mean that its not working? Your code seems to be valid.
Saptur 15-Apr-11 1:34am    
i don't know.. Instead of i use timer mean will it work?

try this Link

Share this answer
If you are unable to use Thread.Sleep for some reason then you can always use a simple dummy for loop.

for(int idelay=0; iDelay < 10000; iDelay++);
Share this answer
BobJanova 15-Apr-11 4:43am    
This causes the CPU to spin uselessly. Thread.Sleep is much better and there is no reason it shouldn't work.
Sandeep Mewara 15-Apr-11 5:51am    
Hmmm... you have point. yet, a way for milli seconds it should be fine.
further, OP was having problem with sleep was just an alternative.
you can use timer
if the thread is not working...
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900