Hi Jon
I tried to strip my problem in a minimal way, and I guess it was just too minimal. The problem is more complex. Second try
public class Base
protected abstract void DoStuff()
public class Derived_1 : Base
protected override void DoStuff() {
public class Derived_2 : Base
private Derived_1[] pool
protected override void DoStuff()
foreach( Base base in pool
base.DoStuff(); // **
The error message when compiling is
<error_message
"C:\Blabla\Derived_2.cs(94): Cannot access protected member Base.DoStuff()' via a qualifier of type 'Base'; the qualifier must be of type 'Derived_2' (or derived from it)
</error_message
The problem arises in my thread pool class. A thread pool (Derived_2) manages several threads (Derived_1), and is a thread itself (Base). The thread pool thread dispatches tasks to idle pool threads. In my project I cannot make DoStuff public, because it is implementation functionality, not public functionality
This makes a lot of patterns impossible to implement elegantly. It forces me to make DoStuff public, whereas the operation is really protected. Internal would work only within the same namespace, and that isn't sufficient in my case (extensible library)
What do you think
PS: I know that there is already a thread pool class in C#. I just wanted my own
Thanks
Tom
----- Jon Skeet [C# MVP] wrote: ----
TT (Tom Tempelaere) <"=?Utf-8?B?VFQgKFRvbSBUZW1wZWxhZXJlKQ==?=" <_N
0SPA|/\|t*******@hotmail.com|/\|APS0_N_>> wrote
The line marked *** doesn't compile.
Yes it does. At least, it does for me. Could you give a short but
complete example which *doesn't* compile. This is what I tried and
managed to compile
public class C
public void F( C other)
this.G()
other.G(); // **
protected void G(
{
// Just to avoid having to compile it to a librar
class Tes
static void Main(
--
Jon Skeet - <sk***@pobox.com
http://www.pobox.com/~skee
If replying to the group, please do not mail me to