| View previous topic :: View next topic |
| Author |
Message |
tomr99 Member
Joined: 30 Jun 2005 Posts: 3
|
Posted: 30/06/05 12:32 Post subject: TFindFile Thread understanding |
|
|
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
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 30/06/05 15:45 Post subject: |
|
|
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.
_________________ Kambiz |
|
| Back to top |
|
 |
tomr99 Member
Joined: 30 Jun 2005 Posts: 3
|
Posted: 30/06/05 17:34 Post subject: Thanks |
|
|
Hi Kambiz,
thanks for reply.
I'm a little bit closer to understanding now.
Greetings
Tom
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 02/07/05 13:54 Post subject: |
|
|
I suggest you to read Multithreading - The Delphi Way. It's a good guide for writing multi-threaded applications in Delphi.
_________________ Kambiz |
|
| Back to top |
|
 |
tomr99 Member
Joined: 30 Jun 2005 Posts: 3
|
Posted: 05/07/05 09:44 Post subject: thanks! |
|
|
thanks, this was a helpfull tip
greetings
tom
|
|
| Back to top |
|
 |
cozturk Member
Joined: 30 Jun 2005 Posts: 29 Location: Istanbul - Turkiye
|
Posted: 18/09/06 16:14 Post subject: |
|
|
| The page unavailable. new link please.
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
|
| Back to top |
|
 |
|