Should I call Stop before reading ElapsedMilliseconds?

断了今生、忘了曾经 提交于 2019-12-21 06:56:09

问题


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?


回答1:


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 http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.elapsedmilliseconds.aspx



来源:https://stackoverflow.com/questions/15720813/should-i-call-stop-before-reading-elapsedmilliseconds

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!