Hello,
I think there is a misunderstanding here. I was not aware of the class you are using here,
PerformanceCounter. But I think this is not the adequate class for your purpose. This is more a class for counting resources like memory, or network access.
What Uwe meant was using the
QueryPerformanceCounter function (C++), which is the actual function used for generating high resolution timestamp on Windows, as I mentioned in my last post.
K.Wagner wrote: ↑Wed 7. Jun 2023, 12:00
You can use the Stopwatch class, which is based on the Windows API function "QueryPerformanceCounter".
Nevertheless, indifferently if this PerformanceCounter class can be used for accurate timestamping generation or not, you are still using different base values for creating a TimeStamp, what still can end in loosing accuracy, and probably you are still substracting two TimeSpam what also can lead to some truncations as I said in my last post too.
I just wrote a small test app that does what I understood you want to do and I see no problems. It looks like:

- Time difference between performance counter tick count at CAN Init and a received message
- Test-Counter.PNG (22.65 KiB) Viewed 11959 times
Each time a mesasge is received, the elapsed time is calculated.
Note that the time shown in Task Manager is the same as the first two values in my test app. The application uses a timer to update the values displayed on the form every second. I have attached the code here in a zip file. It also contains a binary for testing purposes, so you can directly check if this app shows the values as you expect.