timer.tick

  • Thread starter Thread starter Ryan Moore
  • Start date Start date
R

Ryan Moore

is there any way to get a more accurate version of the timer? Basically what
I need it to do something every 33 milliseconds, but for some reason,
setting the timer.Interval=33 does not ensure that my event happens every
33ms (probably because it takes a while to do the event)

Is there any sort of a "Wait" method that allows me to pause for a certain
number of milliseconds?

thnx
 
Hi Ryan!

Is there any sort of a "Wait" method that allows me to pause for a certain
number of milliseconds?

Maybe you are looking for:

public static Thread.sleep(int)

Thread can be found in System.Threading.

With kind regards,

Konrad
 
If you set timer interval to 1 you can use
DateTime check = DateTime.Now.AddMilliseconds(33);

and in timer.tick check if timespan becomes <= 0;

TimeSpan span = (check - DateTime.Now);
if(span <= 0)
// at least 33 ms have passed

I don't know how accurate it is for milliseconds, but for seconds you get
the same exact timespan each time.
 
Back
Top