DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   Watched TopicsWatched Topics     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TFindFile Thread understanding

 
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> Delphi Programming
View previous topic :: View next topic  
Author Message
tomr99
Member


Joined: 30 Jun 2005
Posts: 3

PostPosted: 30/06/05 12:32    Post subject: TFindFile Thread understanding Reply with quote

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
View user's profile Send private message
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1044
Location: Tehran, Iran

PostPosted: 30/06/05 15:45    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
tomr99
Member


Joined: 30 Jun 2005
Posts: 3

PostPosted: 30/06/05 17:34    Post subject: Thanks Reply with quote

Hi Kambiz,

thanks for reply.

I'm a little bit closer to understanding now.

Greetings

Tom
Back to top
View user's profile Send private message
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1044
Location: Tehran, Iran

PostPosted: 02/07/05 13:54    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
tomr99
Member


Joined: 30 Jun 2005
Posts: 3

PostPosted: 05/07/05 09:44    Post subject: thanks! Reply with quote

thanks, this was a helpfull tip

greetings
tom
Back to top
View user's profile Send private message
cozturk
Member


Joined: 30 Jun 2005
Posts: 29
Location: Istanbul - Turkiye

PostPosted: 18/09/06 16:14    Post subject: Reply with quote

The page unavailable. new link please.
Back to top
View user's profile Send private message MSN Messenger
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1044
Location: Tehran, Iran

PostPosted: 18/09/06 16:39    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> Delphi Programming All times are GMT
Page 1 of 1

Add to favorites

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group