Start a stopwatch from specified time

前端 未结 4 1733
一向
一向 2021-01-18 21:04

Im trying to start a stopwatch from a given time (decimal value pulled from a database). However, because the Stopwatch.Elapsed.Add returns a new timespan rather than modify

4条回答
  •  生来不讨喜
    2021-01-18 21:21

    The Elapsed property of StopWatch is read only, which makes sense. A stopwatch simply measures the amount of time that passed between start and stop.

    If you want to add a timespan to the value - get the Elapsed value in a variable and add a timespan to it, after you have measured it (i.e. after stopping).

提交回复
热议问题