PC Review


Reply
Thread Tools Rate Thread

Dispose on base class

 
 
Sonnich Jensen
Guest
Posts: n/a
 
      31st May 2011
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?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make sure this.Test() call base class method in base class constructor Ryan Liu Microsoft C# .NET 2 27th Aug 2006 07:43 PM
Getting a reference to the base class of a base class from an inherited class Edward Forgacs Microsoft C# .NET 1 24th Apr 2004 11:06 AM
variable type that can be declared in a base class this is accessible only to classes that inherit the base class Dan Microsoft ASP .NET 1 24th Mar 2004 09:34 PM
Pass an instantiated base class to a new class that inherits the same class -- Possible?? Brad Navarro Microsoft C# .NET 3 9th Jan 2004 01:07 AM
How to call a base class's base class method Bill Menees Microsoft C# .NET 1 23rd Jul 2003 02:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:55 PM.