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?
Asked
Active
Viewed 459 times
3
-
1Time is time... I guess out of morbid curiosity; why do you need this? – vcsjones Jul 04 '11 at 17:02
-
http://stackoverflow.com/questions/179940/c-convert-utc-gmt-time-to-local-time – reggie Jul 04 '11 at 17:04
-
http://stackoverflow.com/questions/1987824/c-synchronizing-different-time-zones – reggie Jul 04 '11 at 17:04
-
i know it seem a bit odd, but I am working on an odd project. An application that is heavily time/date schedule based. Without going into too much detail, the client is asking for some really crazy stuff in order to offset a shift schedule... IOW.. to start a schedule at say 6am, but because of the way the physical process runs we don't reeeeeally want to start processing data until like 6:15. This app is in a factory, it monitors different pieces of machinery and it uses many schedule variations since not all machines are running at the same time. – danielea Jul 04 '11 at 17:23
2 Answers
2
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.

Kelsey
- 47,246
- 16
- 124
- 162
-
No actually your not off at all. Thats what I am most likely going to have to do. I am researching right now to find the best way to go about it, but yeah, looks like this might be my best alternative. – danielea Jul 04 '11 at 17:32
-
+1. This is the approach I would take. `TimeSpan` is the ideal type to hold an "offset". – Stephen Cleary Jul 04 '11 at 18:05
0
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.

Tristan St-Cyr
- 143
- 4
- 7
-
thank you for the excellent idea. I gave your solution some thought and it would definitely provide some useful functionality, but in my case wouldn't completely fill the bill. Thank you for sharing your thoughts though. I appreciate it! – danielea Jul 04 '11 at 20:39