Re: TStringList OnChange and Threads



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").
.



Relevant Pages

  • Re: Counting lines in big number of files - in parallel.
    ... # or do something else with $filename & lines ... is quite powerfull (72 CPU and fast filesystems) so I would like to ... run the counting in parallel (eg. counting in 72 files at the same ... It will certainly be faster than invoking cat and wc 25000 times. ...
    (comp.lang.perl.misc)
  • Re: Automate version creation? and comparison?
    ... filename that gets incremented by 1 each time if the filename already ... you could have code to display a userform or InputBox into ... I am attempting to automate the saving of different versions. ...
    (microsoft.public.word.vba.general)
  • Re: file access permission?
    ... How about just simple database table, in which you track the locking? ... filename | Contains the filename that is being locked. ... last_action | Timestamp when locking user was active. ... Something similar for queue. ...
    (comp.lang.php)
  • Re: Help please
    ... Okay, so this one had the filename cc_20060120_1034.reg, do you remember ... (pmj just LOVES saving .reg files LOL) ...
    (uk.people.silversurfers)
  • Re: This might be a toughy
    ... Learning macros for this one of event is not practicle for me and it ... Microsoft MVP Excel ... When saving the invoices I've asked them to add the current date to the ... Is it possible to get excel to add the current date to the filename ...
    (microsoft.public.excel.newusers)