>> > Is there a problem having multiple instances of ICS
>> > socket objects on the same thread?

>> Defenitely no problem.
>> The most frequent error when using ICS components in a thread is to
forget
>> you must create the component from with the thread's execute method. If
you
>> create the component from the thread's constructor, then all events will
be
>> executed in the context of the creating thread (usually the main thread).
>> And this may cause a lot of trouble.

> In my current app, I only have a main thread. So, does this, "...this
> may cause a lot of trouble", apply?

Yes, since you are creating new threads. If you create the components in the
thread constructor (or drop it on the form), their event handler will run in
the main thread context which is the active thread when the constructor is
called. You /MUST/ create the component from the Execute method (or any
method called from the Execute), and destroy it from the Execute method.

You cannot have on ICS component (let's talk about FTP as an example)
dropped on a form and the create a few threads, each one using the same
component to do file transfer. That will /not/ work. You need a separate
component for each concurrent file transfert no matter if you use threads or
not.

> I should expect trouble if I have
> multiple ICS components all executing on the main thread?

ICS is asynchronous, so you /DONT NEED/ multithreading to do several things
simultaneously ! You /MAY/ use threads to benefit from multi-processor/core
systems or to do lengthy processing. But this is defenitely required for
ICS. If you want to query 4 webpages at the same time, just use 4 HTTP
client components and call GetAsync on each one. They will all 4 do their
job in parallel without blocking each other and without using threads.

--
francois.pie...@overbyte.be
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to