troubleshooting Question

TDateTime::CurrentDateTime - problem with accurate time in milliseconds

Avatar of Eimund
Eimund asked on
2 Comments1 Solution2900 ViewsLast Modified:

I'm makeing a log where I need a timestamp for each log. The problem is the accuracy of the milliseconds when I request consecutive timestamps. In my log, when requesting a new timestamp within 100ms, it seems that TDateTime::CurrentDateTime jumps 10ms instead of 1ms. A piece of my selfmade log is shown below. As you se least significant millisecond digit is 3, and the change occures from the is the second least significant millisecond digit.

I call the function AddEvent (code snipp attached) from a multithreaded environment by using TThread::Synchronize.

Do any one know the cause of this? And if so, is there a way to get 1ms accuracy of the timestamp?

Eimund Smestad

18.07.2008 09:09:07.073      Data written to Interface 1
0X00 0X9C 0X34 0X3B 0X06 0X6C 0X9F 0XB1 0X7E 0XB7 0XBF 0X55 0XFA 0X40 0XC9 0XD9 0X56 0X96 0XC6 0X3C 0X34 0X3D 0XBA 0X9E 0X4F 0XF5

18.07.2008 09:09:07.083      IN-datalength on interface 1 is set to 26 bytes

18.07.2008 09:09:07.083      OUT-datalength on interface 1 is set to 32 bytes

18.07.2008 09:09:07.103      Data written to Interface 1
0X00 0X5E 0X56 0XB2 0XEE 0X89 0X95 0X05 0X2B 0X16 0X80 0X97 0X95 0X34 0X31 0X80 0X45 0X22 0XE2 0XAA 0X2D 0X81 0XB5 0X83 0X66 0X18 0XCA 0X92 0XA8 0XA6 0X80 0X88

18.07.2008 09:09:07.113      IN-datalength on interface 1 is set to 32 bytes

void CUSB::Log::AddEvent(AnsiString event, bool blanckline)
	AnsiString text;
	tid = tid.CurrentTime();
	LongTimeFormat = "hh:nn:ss.zzz";
	text = "" + tid.CurrentDateTime() + "\t" + event;

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros