private void DoCheckTimeout()
{
// Note that both, Environment.TickCount and timeoutOccursAt are ints and can overflow and become negative.
// See the comment in StartTimeoutWatch().
int currentMillis = Environment.TickCount;
if (currentMillis < _timeoutOccursAt)
return;
if (0 > _timeoutOccursAt && 0 < currentMillis)
return;
#if DEBUG
if (runregex.Debug)
{
Debug.WriteLine("");
Debug.WriteLine("RegEx match timeout occurred!");
Debug.WriteLine("Specified timeout: " + TimeSpan.FromMilliseconds(_timeout).ToString());
Debug.WriteLine("Timeout check frequency: " + TimeoutCheckFrequency);
Debug.WriteLine("Search pattern: " + runregex.pattern);
Debug.WriteLine("Input: " + runtext);
Debug.WriteLine("About to throw RegexMatchTimeoutException.");
}
#endif
throw new RegexMatchTimeoutException(runtext, runregex.pattern, TimeSpan.FromMilliseconds(_timeout));
}