El 18/06/2017 a las 22:44, el es via Lazarus escribió:
Hence the object, would have to have ITS callback routine be something
like a TNotifyEvent ( procedure(AObject: TSomeObject) of object, or
something), and the flag set is set when the callback returns to the
object context like
procedure TSomeObject.Callback;
// this procedure is enQueue()d by the thread
begin
if Assigned({Self.}FSomeObjectNotifyEvent) then
FSomeObjectNotifyEvent(Self);
Hello,
Just exit the procedure and there is not free problem. You will get an
exception when you use object data, not object code.
procedure TSomeObject.Callback;
// this procedure is enQueue()d by the thread
begin
if Assigned({Self.}FSomeObjectNotifyEvent) then
FSomeObjectNotifyEvent(Self);
Self.CanBeDestroyed := true;
Exit;
end;
After you set CanBeDestroyed to true you must consider all data as
RANDOM, so don't access any property or variable.
Remember that creating and destroying threads is very expensive in CPU time.
--
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus