tag:blogger.com,1999:blog-29331675.post1570873311312221531..comments2024-03-05T17:37:00.995+01:00Comments on The Delphi Geek: OmniThreadLibrary patterns – Task controller needs an ownergabr42http://www.blogger.com/profile/06903558857617342477noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-29331675.post-38125374086411696592017-01-11T17:05:20.698+01:002017-01-11T17:05:20.698+01:00Doubt: You say "CreateTask(MyWorker).Run;&quo...Doubt: You say "CreateTask(MyWorker).Run;" will cause access violation. But the first example Beep uses a code exactly like that?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-29331675.post-32890077445809419542009-11-30T18:20:40.046+01:002009-11-30T18:20:40.046+01:00Reference counting is OK. OTL is designed around t...Reference counting is OK. OTL is designed around that concept. It's just sometimes that you have to keep this in mind ...gabr42https://www.blogger.com/profile/06903558857617342477noreply@blogger.comtag:blogger.com,1999:blog-29331675.post-91235272652565286562009-11-30T16:54:24.586+01:002009-11-30T16:54:24.586+01:00When using TInterfacedObject I got more problems t...When using TInterfacedObject I got more problems than advantages. These errors are very difficult to find. So I wrote a different IUnknown implementation with no references count. <br /><br />BTW in Delphi 2010 I found Embarcadero's similar implementation :)Alexhttp://blog.frantic.imnoreply@blogger.comtag:blogger.com,1999:blog-29331675.post-15250548826398994332009-11-30T12:08:02.471+01:002009-11-30T12:08:02.471+01:00Been there, cause incredible lots of problems and ...Been there, cause incredible lots of problems and pain (for me), won't try it again...gabr42https://www.blogger.com/profile/06903558857617342477noreply@blogger.comtag:blogger.com,1999:blog-29331675.post-92082104138062544182009-11-30T11:16:58.633+01:002009-11-30T11:16:58.633+01:00But you can call TInterfacedObject._AddRef in Run ...But you can call TInterfacedObject._AddRef in Run procedure and TInterfacedObject._Release in Terminate procedure?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-29331675.post-49282079131642111082009-11-30T09:28:53.914+01:002009-11-30T09:28:53.914+01:00Then you end with task controller referencing itse...Then you end with task controller referencing itself which causes all sorts of problems when reference count drops to zero.<br /><br />I was thinking more along the lines of .Unobserved being implicitly called in all occasions but I don't know yet if that's a good idea in all cases.gabr42https://www.blogger.com/profile/06903558857617342477noreply@blogger.comtag:blogger.com,1999:blog-29331675.post-666505647938422402009-11-30T09:09:33.600+01:002009-11-30T09:09:33.600+01:00Should Run not add a reference to the interface in...Should Run not add a reference to the interface instance and remove that reference when done?Ritsaert Hornstranoreply@blogger.com