33

Can I get the elapsed time since I have called Start on a stopwatch using ElapsedMilliseconds without calling Stop? I have searched a lot round the internet but only saw examples where ElapsedMilliseconds is called after Stop. Is this value filled on a call to Stop or is it always correct?

4

1 回答 1

43

You can query the properties Elapsed, ElapsedMilliseconds, and ElapsedTicks while the Stopwatch instance is running or stopped. The elapsed time properties steadily increase while the Stopwatch is running; they remain constant when the instance is stopped.

— From https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.stopwatch.elapsedmilliseconds#remarks

于 2013-03-30T16:30:39.477 回答