Hi all
I have some components for which I have my own base class. In my base
class I have added a "MyDispose" which is called upon dispose (from
the designer).
The problem is, that it is called only once, not for every instance of
my real class. I would have expected that, that MyComp1: baseclass and
MyComp2:baseclass would have each own Dispose called. But it seems
that only once.
Any ideas?
public class baseclass
{
Mydispose() // called only once
{
stuff();
createthread(controlled by Monitor)
{
calculations();
}
}
}
public partial class MyComp1 : baseclass
{
stuff()
{
createthread();
}
}
public partial class MyComp2...n : baseclass
{
stuff()
{
createthread();
}
}
The thing is, that if only one component creates a thread, it will
work. (the dispose pulses it and closes it). But if both components
creates their own thread, it will only terminate one of them. The
dispose is only called once.
But, when only one thread is created, it will go to the component with
the thread.
Or is the base class the same for all of them? They should have their
own instances, shouldnt they?
|