Re: TStringList OnChange and Threads
- From: David Perkins <no@xxxxxxx>
- Date: Tue, 05 Dec 2006 21:47:57 +0000
I have a thread pool which is donwloading files via HTTP.
Each thread is saving the result to a file.
Now, I'd like to have a TStringList where each thread writes the local
filename using Critical Sections, so that the main thread can further
process these files (has to be single threaded).
It would be handy to use the OnChange event of TStringList, to notify
the main thread, that there is some work to do.
But I guess everything in such a event handler will happen in the
donwload-threads context and not in the main thread's right?
What is the best way to this? Polling, means locking and counting
periodically the Stringlist from the main thread?
How would you do this?
You could create an event (Win API "CreateEvent") and set it as 'Flagged' when there is something in the queue. Then, in your main thread, test the event ("WaitForSingleObject").
.
- Follow-Ups:
- Re: TStringList OnChange and Threads
- From: theo
- Re: TStringList OnChange and Threads
- References:
- TStringList OnChange and Threads
- From: theo
- TStringList OnChange and Threads
- Prev by Date: Re: Confusing ... "Borland Delphi Team" ??
- Next by Date: Re: Confusing ... "Borland Delphi Team" ??
- Previous by thread: Re: TStringList OnChange and Threads
- Next by thread: Re: TStringList OnChange and Threads
- Index(es):
Relevant Pages
|