theinvisibleGhost wrote:
Any more ideas anyone?
Cheers
theinvisibleGhost wrote: Thanks for your reply.
The app is windows based.
I'm having this occur in more than once class, although it's occured
most in a class
I call LEDControl (Simulates an LED!). The LED has a flash timer (to
make it flash!)
The timer is created as a private attribute on creation of the LED
object.
No dispose methods are called within the class except on disposal of
the LED object.
The LED itself is definitley not disposed of (I can see it for a
start)....
The timer is never set to null or infact set to anything after the
line
private System.Timers.Timer flashTimer = new System.Timers.Timer();
so as far as I can see it should always have one and only onereference
to it, until
the LED is disposed off (When the application ends).
I tried placing a MessageBox in the Dispose event of the LED, and it
never showed,
so the timer cannot have been disposed of there.....
Found the problem, eventually!
It is a known bug if you search hard enough across the Net.
I found a link
http://www.kbalertz.com/kb_842793.aspx
Basically as soon as you stop a timer, the internal
System.Threading.Timer becomes available for Garbage Collection,
sometimes causing the elapsed event not to occur, or sometimes
causing a disposed reference exception.
Although not described in the article, my soloution was
to create a new timer every time the timer was to be
stopped and re-add the elapsed events. Not efficient but easy,
and not a problem processor wise with me.
This has totally solved my problem.
Cheers for all who responded.
T.