Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Jan : Re: AThread.Data... 2 different objects stored..

www.cryer.info
Managed Newsgroup Archive

Re: AThread.Data... 2 different objects stored..

Subject:Re: AThread.Data... 2 different objects stored..
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Wed, 16 Jan 2008 16:17:32

"Jamie Dale" <jamie.dale@yahoo.com> wrote in message
news:478e8daf$1@newsgroups.borland.com...

> The problem is the OnDisconect method. I need to free the
> object but I am not sure how to determine what object it
> is - TUser or TFileClient.

If both types are classes that are derived from TObject, then you don't need
to know at all.  The TObject destructor is virtual so just call Free() on
the Data property directly and let polymorphism do the rest for you, ie:

    AThread.Data.Free;
    AThread.Data := nil;

> I tried: If AThread.Data = TUser... Incompatible types..

You need to use the 'is' operator instead:

    If AThread.Data is TUser then

Note that such a comparison will only work if both types really are TObject
descendants.


Gambit

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive