Is there any reason why you don't just retrieve a DateTime at the start and, as necessary to have the value, use an DateTime.Now.Subtract(origDateTime) and use the TimeSpan result for what you need? Or is this updating something with every tick?
EDIT
Also, as with Timers, you set a "Tick" interval, so you don't need to sleep them. Every tick will execute the callback saving you the trouble of using a while...sleep. But bare in bind, while in threading territory, and I can't verify as it's been a while since I've used timers, you may need to lock() the variable you're modifying as it's in a separate thread as nothing is securing that another method isn't altering the same value.
EDITv3
Here's version 3 of the edit. You have two classes, both avoiding the use of a timer (which your CPU will thank me later ;-p) SystemClock is a typical one-per-second interval rate. VariableSystemClock allows you to specify the rate of the increases. I also changed the way you get the value from a property to a method, and even used inheritance. ;-)
SystemClock.cs
public class SystemClock
{
protected DateTime _start;
public SystemClock()
{
this._start = DateTime.UtcNow;
}
public virtual Int32 getSystemTime()
{
return Convert.ToInt32(Math.Floor(DateTime.UtcNow.Subtract(this._start).TotalSeconds));
}
}
VariableSystemClock.cs
public class VariableSystemClock : SystemClock
{
private TimeSpan _interval;
public VariableSystemClock(TimeSpan interval)
: base()
{
this._interval = interval;
}
public override Int32 getSystemTime()
{
Double ellapsed = DateTime.UtcNow.Subtract(this._start).Ticks / this._interval.Ticks;
return Convert.ToInt32(Math.Floor(ellapsed));
}
}
program.cs (so you can test it in a console application (project->new->console application)
class Program
{
static void Main(string[] args)
{
SystemClock oncePerSecond = new SystemClock();
VariableSystemClock oncePerInterval = new VariableSystemClock(TimeSpan.FromSeconds(2));
Console.WriteLine("Start:");
Console.WriteLine(" oncePerSecond: {0}", oncePerSecond.getSystemTime());
Console.WriteLine(" oncePerInterval: {0}", oncePerInterval.getSystemTime());
Console.WriteLine();
for (Int32 i = 0; i < 10; i++)
{
// sleep three seconds
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(2));
// display output
Console.WriteLine("Interval {0}:", i);
Console.WriteLine(" oncePerSecond: {0}", oncePerSecond.getSystemTime());
Console.WriteLine(" oncePerInterval: {0}", oncePerInterval.getSystemTime());
Console.WriteLine();
}
Console.WriteLine("End:");
Console.WriteLine(" oncePerSecond: {0}", oncePerSecond.getSystemTime());
Console.WriteLine(" oncePerInterval: {0}", oncePerInterval.getSystemTime());
Console.WriteLine();
}
}
Feel free to play with both the oncePerInterval construct and the Sleep within the for loop.