danielea
danielea

Reputation: 318

Multiple System Time Clock

I'm looking for a way to have multiple time clocks running along side the system time clock that are also accessible programatically so that I could access their time values much like I can system time with C#. A third party framework is acceptable. Anyone have any ideas, or even heard of such a need?

Upvotes: 3

Views: 494

Answers (2)

Tristan St-Cyr
Tristan St-Cyr

Reputation: 143

System.Diagnostics.Stopwatch might be what you're looking for.

// Start the Stopwatch
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
// do something...

// perhaps the rest of this could be in a method
TimeSpan ts = stopWatch.Elapsed;
return ts.TotalMilliseconds

You could keep multiple Stopwatch instances and use the TotalMilliseconds as a sort of independent "system" time.

Upvotes: 0

Kelsey
Kelsey

Reputation: 47726

This might be totally off but why not just use the system clock as is and store offsets for your 'other clocks' (not sure what you are trying to do exactly) and wrappers to make them work similar? Still one clock, just different views to give different perspectives.

Upvotes: 2

Related Questions