H
Hagay Lupesko
Hi,
I've encountered a strange phenomena which appears to me as a bug:
I have an engine that uses a System.Threading.Timer to invoke a delegate
every X minutes.
The code looks something like this:
TimerCallback callBack = new TimerCallback(Run); // run is obviously a
method
analysisTimer = new Timer(callBack, null, 0, delay);
Console.ReadLine();
Everything works just fine when the code is build in Debug mode, but when
the code is build in Release mode the delegate is invoked once only.
After creating debug symbols for the Release mode it looks like the timer
class is optimized away...
The workaround solution I used was declaring the timer as static.
But obviously it's not very nice...
Any clue as to is this a bug, or what's wrong with the code ?
Thanks, Hagay.
I've encountered a strange phenomena which appears to me as a bug:
I have an engine that uses a System.Threading.Timer to invoke a delegate
every X minutes.
The code looks something like this:
TimerCallback callBack = new TimerCallback(Run); // run is obviously a
method
analysisTimer = new Timer(callBack, null, 0, delay);
Console.ReadLine();
Everything works just fine when the code is build in Debug mode, but when
the code is build in Release mode the delegate is invoked once only.
After creating debug symbols for the Release mode it looks like the timer
class is optimized away...
The workaround solution I used was declaring the timer as static.
But obviously it's not very nice...
Any clue as to is this a bug, or what's wrong with the code ?
Thanks, Hagay.