AMT_VDM
asked on
How to determine timespan to the milliseconds on PDAs?
I'm using C# (VS2005). Using the function GetDate.Ticks only returns me values with an accuracy of a second on an IPAQ2490.
i.e. 633082888810000000 long
or 633082888820000000 long
So this is unreliable to find out timedifferences of less than a second which is what I need to do.
Here's how I tried to implement it earlier:
long _TicksSinceLastRead = DateTime.Now.Ticks - _lngLastReceived;
if (_TicksSinceLastRead < _lngMinimalTimeForResponse )
Thread.Sleep((int)(_lngMin imalTimeFo rResponse - _TicksSinceLastRead)/10000 );
Can you provide me with code/free components I can use to get an accuracy in the milliseconds range?
Best regards
AMT_VDM
i.e. 633082888810000000 long
or 633082888820000000 long
So this is unreliable to find out timedifferences of less than a second which is what I need to do.
Here's how I tried to implement it earlier:
long _TicksSinceLastRead = DateTime.Now.Ticks - _lngLastReceived;
if (_TicksSinceLastRead < _lngMinimalTimeForResponse
Thread.Sleep((int)(_lngMin
Can you provide me with code/free components I can use to get an accuracy in the milliseconds range?
Best regards
AMT_VDM
ASKER
It does not change the accuracy - here are some values:
I used your code as supplied - just did some variable renames.
dTimeAfterSend.Millisecond 0 int
dTimeBeforeSend.Millisecon d 0 int
span.Milliseconds 0 int
I used your code as supplied - just did some variable renames.
dTimeAfterSend.Millisecond
dTimeBeforeSend.Millisecon
span.Milliseconds 0 int
Have you tried GetTickCount()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Missed one thing you will need to replace the " throw new ApplicationException();" lines with appropriate exception or may be just put " throw new Exception();"
ASKER
Thanks for the Code Fragment, checoo - exactly what I was lookig for.
As a sidenote to complete the thread: you need to use System.Runtime.InteropServ ices to make use of the DLLImport Attribute - add the following line and it should work fine:
using System.Runtime.InteropServ ices;
Best regards
AMT_VDM
As a sidenote to complete the thread: you need to use System.Runtime.InteropServ
using System.Runtime.InteropServ
Best regards
AMT_VDM
DateTime dtPrevious;
DateTime dtNext;
// get previous and next dates
TimeSpan span = dtNext - dtPrevious;
long milliseconds = span.Milliseconds;