TFindFile Thread understanding

Please discuss general Delphi programming topics here.

TFindFile Thread understanding

Postby tomr99 » June 30th, 2005, 12:32 pm

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
tomr99
Member
Member
 
Posts: 3
Joined: June 30th, 2005, 12:17 pm

Postby Kambiz » June 30th, 2005, 3:45 pm

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
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Thanks

Postby tomr99 » June 30th, 2005, 5:34 pm

Hi Kambiz,

thanks for reply.

I'm a little bit closer to understanding now.

Greetings

Tom
tomr99
Member
Member
 
Posts: 3
Joined: June 30th, 2005, 12:17 pm

Postby Kambiz » July 2nd, 2005, 1:54 pm

I suggest you to read Multithreading - The Delphi Way. It's a good guide for writing multi-threaded applications in Delphi.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

thanks!

Postby tomr99 » July 5th, 2005, 9:44 am

thanks, this was a helpfull tip

greetings
tom
tomr99
Member
Member
 
Posts: 3
Joined: June 30th, 2005, 12:17 pm

Postby cozturk » September 18th, 2006, 4:14 pm

The page unavailable. new link please.
cozturk
Moderator
Moderator
 
Posts: 63
Joined: June 30th, 2005, 5:39 am
Location: Istanbul - Turkiye

Postby Kambiz » September 18th, 2006, 4:39 pm

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
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 6 guests

cron