There is a class. It has a Start() method. It is necessary at any time after the execution of the method to find out how much time has passed since then. At the same time, a change in the system time should not affect the result. The operation should be minimally costly.

So far, only the use of Stopwatch has occurred. But, firstly, I do not know how expensive it is, and secondly, it seems to me that it is wrong to use System.Diagnostics in this case. Do not target the use of something. Or maybe it's prejudice :)

    2 answers 2

    Use, do not be afraid, everyone does.

      In fact, Stopwatch is free. It uses QueryPerformanceCounter , which in turn can be implemented by a single processor command. Accordingly, the difference in time is simply mathematics over two numbers.

      Another option is to call GetTickCount via P / Invoke, but I think there’s no point in that.