[C#] - Inherit question

Asmod

New member
Joined
Jan 26, 2004
Messages
2
Just started playing with C# after many years of Delphi coding. One question I have is to do with Class inheritance.

In Delphi you could do things like this

Code:
TMyClass = Class(TThread)
....
Public
    FVariable : string;
End;


MyClass : TMyClass;

MyClass := TMyClass.Create(True);
MyClass.FVariable := Test;

but as I found in C# there seems to be no way of inheriting a thread due to the fact the class is sealed. Im guessing Im just being narrow minded and my past Delphi experience is making this harder than is needs to be.

Am I overlooking something simple here or can it just not be done?

I would like to create a class that is basically a thread but with a couple of extra variables and functions in it.

Thanks for any help!
 
you cant inherit sealed classes that is true but i ask why do you have to inherit a Thread? You can point to any method since it uses delegates..so there should be no need, if you got a problem to realize something just post it and we will look together for a solution, ok? :)
 
Only wanted to inherit a thread so I could create thread specific variables and procedures.

If I have a program that reads data from a huge array Id like to pass off jobs to a thread along with an id number which would reference part of the array and maybe some other information too.

Its the passing variables/parameters to a thread that I cant work out. I thought maybe youd have to create your own class and inherit a thread but that appears impossible so there must be some way to pass this info over!

Thanks
 
uhm normally a thread just opens something like a "2nd process" so like a second application you can work at the same time on more than one thing, normally you pass the arguments to the object of the method where the threadstart delegate aims to
 


Write your reply...
Back
Top