Beispiel #1
0
        static void SetReloadWorkflowTimer()
        {
            DateTime reloadTime = workflowInstance.GetWorkflowNextTimerExpiration();

            if (reloadTime == DateTime.MaxValue)
            {
                // WaitForMessage case
                readyHandle.Set();
            }
            else
            {
                TimeSpan timeDifference =
                    reloadTime -
                    DateTime.UtcNow +
                    // account for the race in this code
                    // the timer is set later than the timespan was measured
                    new TimeSpan(0, 0, 0, 0, 1);

                Timer timer = new System.Threading.Timer(
                    new TimerCallback(ReloadWorkflow),
                    null,
                    timeDifference < TimeSpan.Zero ? TimeSpan.Zero : timeDifference,
                    new TimeSpan(-1));
            }
        }