Page 1 of 1

TFindFile Thread understanding

PostPosted: June 30th, 2005, 12:32 pm
by tomr99
Hi,
first thank you for your components!

I've looked at the sourcecode of the FindFile-component to understand thread-handling (I'm new to this).

And now I've got two questions:
1) You don't use Synchronize or something like that and it works even if I fill Listviews in the FoundEvent. I thought the VCL is not threadsave ? So - why does it work ?

2) What is the difference of declaring functions inline (in another function/procedure) or as member-functions ?

Thanks!

Greetings,
Tom

PostPosted: June 30th, 2005, 3:45 pm
by Kambiz
When we tell something is not thread safe, it means the stuff should not be accessed or/and modified by more than one thread at the same time. So, if we guarantee that only one thread at the same time be accessed or/and modified, everything works fine.

Actually using Synchronize method of TThread class causes the main VCL thread calls the procedure. This increases the chance of dead-lock. And in the other hand, we don't use all benefits of multi-threading. Windows provides several objects for synchronization (Mutex, Critical Section, Event, and Semaphore), which I would rather to use them.

In TFindFile, I suppose when somebody uses the component as threaded, she/he knows how to use it in a thread safe maner. In my demo program there was no need for synchronization, but in some other usages the synchronization could be a must.

There's no inline function in Delphi (and gerenaly Pascal). I guess you mean nested functions. If so, it's just for making the code modular and easier to understand/manage.

Thanks

PostPosted: June 30th, 2005, 5:34 pm
by tomr99
Hi Kambiz,

thanks for reply.

I'm a little bit closer to understanding now.

Greetings

Tom

PostPosted: July 2nd, 2005, 1:54 pm
by Kambiz
I suggest you to read Multithreading - The Delphi Way. It's a good guide for writing multi-threaded applications in Delphi.

thanks!

PostPosted: July 5th, 2005, 9:44 am
by tomr99
thanks, this was a helpfull tip

greetings
tom

PostPosted: September 18th, 2006, 4:14 pm
by cozturk
The page unavailable. new link please.

PostPosted: September 18th, 2006, 4:39 pm
by Kambiz
cozturk wrote:The page unavailable. new link please.

Here is link to a mirror:
http://experience.masalas.org/assets/files/tutorial_multithreading_the_delphi_way_v1.1.zip