System.Threading.Timer improper function in Release mode
From: Hagay Lupesko (hagayl_at_nice.com)
Date: 05/11/04
- Next message: Daniel O'Connell [C# MVP]: "Re: Hash Code?"
- Previous message: Jon Skeet [C# MVP]: "RE: Need to remove the integer part and keep the fractional part of a double or decimal"
- Next in thread: Vijaye Raji: "Re: System.Threading.Timer improper function in Release mode"
- Reply: Vijaye Raji: "Re: System.Threading.Timer improper function in Release mode"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 11 May 2004 11:51:21 +0300
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.
- Next message: Daniel O'Connell [C# MVP]: "Re: Hash Code?"
- Previous message: Jon Skeet [C# MVP]: "RE: Need to remove the integer part and keep the fractional part of a double or decimal"
- Next in thread: Vijaye Raji: "Re: System.Threading.Timer improper function in Release mode"
- Reply: Vijaye Raji: "Re: System.Threading.Timer improper function in Release mode"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|