2
votes
Vote UpVote

OmniThreadLibrary patterns – Task controller needs an owner

The Delphi Geek – Pop quiz. What’s wrong with this code?CreateTask(MyWorker).Run;Looks fine, but it doesn’t work. In most cases, running this code fragment would cause immediate access violation.This is a common problem amongst new OTL users. Heck, even I have fallen into this trap!The problem here is that CreateTask returns IOmniTaskControl interface, or task controller. This interface must be stored into some persistent location, or task controller would be destroyed immediately after Run is called (because the reference count would fall to 0).A common solution is to just store the interface in some ...
Favorite? Off-Topic? gabr @ 2009-11-30 09:58

Statistics

Visits: 410
Votes: 2
Favorites: 1
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

borax
Tier777
Subscribe:
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News

Sponsor

 
Please login or register to use this functionality.
(click on this box to dismiss)