// if the next occurence is more than Int32.MaxValue millisecs away,
// loop to work around the limitations of EventWaitHandle.WaitOne()
if (sleepSpan.TotalMilliseconds > Int32.MaxValue)
{
var idleTime = GetReasonableIdleWaitTimeSpan();
var iterationCount = Math.Truncate(sleepSpan.TotalMilliseconds / idleTime.TotalMilliseconds);
for (var i = 0; i < iterationCount; i++)
{
// Wait for the idle timespan (or until a Set() is called).
if(_ewh.WaitOne(idleTime)) { break; }
}
}
else
{
// if the next occurence is in the past, trigger right away
if (sleepSpan.TotalMilliseconds < 0) { sleepSpan = TimeSpan.FromMilliseconds(25); }