Board index » cppbuilder » Question about vcl object using with thread object

Question about vcl object using with thread object

The thread is using the IdFTP over the Form, but i have to generate several
objects from both types at runtime, i know how to do that, but with more
than one of each, its hard to tell the thread which IdFTP it has to use, so
at this point i am thinking that i will use a vector to store them into it,
and add and "kill" them at runtime when needet (when the thread has done his
job, it should delete the IdFTP too).
But still, i have no idea how to tell the thread which IdFTP it has to use,
maybe someone can help me with an idea.

Another idea of mine was to inherit one class from both ( my thread and the
IdFTP), is this posible?

Or are there better ways how to manage all that?

 

Re:Question about vcl object using with thread object


Quote
"pera" <pic...@gmx.net> wrote in message

news:3dce49d1$1@newsgroups.borland.com...

Quote
> But still, i have no idea how to tell the thread which
> IdFTP it has to use, maybe someone can help me with an idea.

You could try passing the appropriate TIdFTP pointer to the thread's
constructor and then have the constrctor store a local copy of the pointer
for the thread to use in its Execute() method.

Quote
> Another idea of mine was to inherit one class from both ( my
> thread and the IdFTP), is this posible?

The VCL doesn't allow for multiple inheritance.

Quote
> Or are there better ways how to manage all that?

If a thread is going to be for a specific TIdFTP, then you could try having
the thread allocate it's own internal TIdFTP instance rather than using one
from the form.

Gambit

Re:Question about vcl object using with thread object


Quote
> > But still, i have no idea how to tell the thread which
> > IdFTP it has to use, maybe someone can help me with an idea.

> You could try passing the appropriate TIdFTP pointer to the thread's
> constructor and then have the constrctor store a local copy of the pointer
> for the thread to use in its Execute() method.

I am trying something similar, but "a pointer to the constructor" is much
better ;)

Quote
> > Another idea of mine was to inherit one class from both ( my
> > thread and the IdFTP), is this posible?

> The VCL doesn't allow for multiple inheritance.

> > Or are there better ways how to manage all that?

> If a thread is going to be for a specific TIdFTP, then you could try
having
> the thread allocate it's own internal TIdFTP instance rather than using
one
> from the form.

Will that work, and what kind of Owner is the TIdFTP getting, the thread
ones?
I tried that in the past, somehow i couldnt access the TIdFTP object within
the thread, maybe i did something wrong, i cant remember, but ill try that
again.

i appreciate your help, thanks

Re:Question about vcl object using with thread object


Quote
"pera" <pic...@gmx.net> wrote in message

news:3dceda34@newsgroups.borland.com...

Quote
> I am trying something similar, but "a pointer to the
> constructor" is much better ;)

Please elaborate.

Quote
> Will that work

Should

Quote
> and what kind of Owner is the TIdFTP getting

None.  Just assign NULL, and be sure to free the IdFTP when you terminate
the thread.

Gambit

Other Threads