Skip to content

Instantly share code, notes, and snippets.

@punmechanic
Created January 7, 2014 08:16
Show Gist options
  • Save punmechanic/8296168 to your computer and use it in GitHub Desktop.
Save punmechanic/8296168 to your computer and use it in GitHub Desktop.
Tasks in .NET 4.0
_internalTickerTask = new Task(InternalTicker, TaskCreationOptions.LongRunning);
_internalTickerTask.Start();
private void InternalTicker()
{
while (IsAutomaticallyUpdating)
{
if (!(_internalClock.ElapsedMilliseconds >= _ticksIntervalMilliseconds))
continue;
Update(_internalClock.ElapsedMilliseconds);
_internalClock.Reset();
Thread.Sleep(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment