Abaksoft Posted July 10, 2015 Share Posted July 10, 2015 Hi Farshad,In the same optic of :http://forums.unigui.com/index.php?/topic/5116-is-a-standard-delphi-unit-thead-safe/?hl=thread+safeI created a DataModule unit and write there my Class :Unit scool;Type Tscool=class(DataModule)I do this to insure that all my funtions will be thread safe.Ok, now how can i inherite Tscool from an other thread safe class ?Can i do some think like:Type Tscool = Class(TUniversity)And create only University unit as a DataModule ?Thx... Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted July 12, 2015 Author Share Posted July 12, 2015 Oh...sorry i did'nt explain well, Here is a simple OOP sample, wich describe a classical inhireted classes. unit Class_Bird; interface uses Class_Animal; type TBird=Class(TAnimal) private fWeight:integer; procedure SetWeight(value:integer); public error:boolean; Constructor Create; function eat:string; override; published property Weight:integer read fWeight write SetWeight; end; implementation { TAnimal } function TBird.eat:string; var str:string; begin // fWeight in gr if fWeight<1000 then str:='And I need 50 seeds per day !' else if (fWeight>=1000) and (fWeight<2000) then str:='And I need 80 seeds per day !' else str:='And I need 100 seeds per day !'; result:=inherited + #13+ str; end; If i try to write this in an Unigui Thread Safe Unit , the recommended solution is to use UniGui DataModule. The problem is that I can'nt inhereted my Class TBird from TAnimal, firstly and from TDataModule on the other hand ! typeTBird=Class(TAnimal) ??? TBird=Class(TDataModule) ??? In others words, How can I inhereted a TDataModule Class1 from an other TDataModule Class2 ? (each class is declared on separate DataModule). Thx... Animal.zip Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted July 12, 2015 Administrators Share Posted July 12, 2015 As long as your module doesn't use any global variable it is threadsafe. It is important to know that how you use this module in your code. How this module is created in runtime? Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted July 12, 2015 Administrators Share Posted July 12, 2015 I analyzed your code. You are using simple classes inherited from TObject. There are not thread-safety considerations with these objects. You dynamically create and destroy them each time you use them which is OK. Are there any specific things regarding your code which you like to know? Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted July 12, 2015 Author Share Posted July 12, 2015 Thank you very much... Best Regards. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.