Re: DateTime.Now update rate???
Quote:
Originally Posted by laitinen
the DateTime.Now property; ... the resolution is 10ms on Windows NT 3.5 and later, and 55 ms on Win98.
However the DateTime.Ticks property has an accuracy of 100 nano seconds;
Thank you for reminding me of the limited resolution of DateTime.Now. When looking at your link I remember reading that once before... Problem is that the only static function I know giving the number of ticks is DateTime.Now.Ticks, which consequently also only updates every 10ms. Does anyone know of a tick count function or other similar that is more 'up to date'?
Quote:
Originally Posted by K7SN
I wonder why you don't just create a simple Static Class, setting the seed the first time you invoke the utility, and as they say "Set it and Forget it".
I agree with your idea. Actually my post was intended to treat the problem arising because of creating new random objects all the time. That is best avoided by just keeping one object around.
Re: DateTime.Now update rate???
Hi Johan!
To get the highest accuracy available in your system you should use the win32 api functions QueryPerformanceCounter and QueryPerformanceFrequency.
I have never used this in C#, only in unmanaged c++ with very good results. In one of my projects in c++ I got the time with 0.3ms frequency. Very good.
However, take a look at this article for using these functions in c#; High-Performance Timer in C#
You might also have a look at this; Describes how to use the QueryPerformanceCounter function to time application code
Hope this answered your question!
Regards,
Laitinen