protected void intervalCallback()
{
TimerWokeup = DateTime.UtcNow;
lock (syncLock)
{
// We just woke up. Verify we aren't either still running from a previous wakeup,
// or stopping because the app is shutting down, before we proceed.
if (TaskRunning || ShuttingDown)
return;
// The task isn't running. Flag that we're now running so the next wakeup won't
// start a second thread until we unflag.
TaskRunning = true;
// TaskRunning is signaled to on here; it has to be signaled to off in the Thread we're creating, in a later method (taskActionWrapper).
}
// Track wakeups that actually kick off the task
TaskStarted = DateTime.UtcNow;
// Build the thread and run the task action on it at BelowNormal
taskThread = new Thread(taskActionWrapper);
taskThread.Priority = ThreadPriority.BelowNormal;
taskThread.IsBackground = true;
taskThread.Start();
}