D
Deiussum
I'm running into an issue where I have a timer that appears to be timing
out immediately, when it shouldn't be timing out for about int.MaxValue
milliseconds. I have written a small app that isolates the problem and
was wondering if anyone had any ideas on what I am doing wrong, or if
there is some known bug, or I am exceeding some known maximum (which I
can't seen to find in documentation anywhere...)
Anyway, the following code used to appear to work fine. I didn't let it
run for the full 24 days, but the timer function didn't execute after
letting it run for a few hours. Now, the timer function gets executed
immediately. Here's the code:
using System;
class Test
{
static void Main(string[] args)
{
try
{
TimeSpan oSpan = TimeSpan.FromMilliseconds(int.MaxValue);
Console.WriteLine("Waiting for {0}", oSpan);
System.Threading.Timer oTimer = new System.Threading.Timer(
new System.Threading.TimerCallback(Thread),
null, oSpan, TimeSpan.FromMilliseconds(-1));
while(true);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
Console.WriteLine("Press enter to continue...");
Console.ReadLine();
}
}
static void Thread(object o)
{
Console.WriteLine("Thread...");
}
}
out immediately, when it shouldn't be timing out for about int.MaxValue
milliseconds. I have written a small app that isolates the problem and
was wondering if anyone had any ideas on what I am doing wrong, or if
there is some known bug, or I am exceeding some known maximum (which I
can't seen to find in documentation anywhere...)
Anyway, the following code used to appear to work fine. I didn't let it
run for the full 24 days, but the timer function didn't execute after
letting it run for a few hours. Now, the timer function gets executed
immediately. Here's the code:
using System;
class Test
{
static void Main(string[] args)
{
try
{
TimeSpan oSpan = TimeSpan.FromMilliseconds(int.MaxValue);
Console.WriteLine("Waiting for {0}", oSpan);
System.Threading.Timer oTimer = new System.Threading.Timer(
new System.Threading.TimerCallback(Thread),
null, oSpan, TimeSpan.FromMilliseconds(-1));
while(true);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
Console.WriteLine("Press enter to continue...");
Console.ReadLine();
}
}
static void Thread(object o)
{
Console.WriteLine("Thread...");
}
}