Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 17651, Count CR - Count lines in files.

by Kevin Jesshope Email: Anonymous


Multi-Threaded count of lines in a file or files. It is not a flashy program - just functional.
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 6.0  to 6.0 763 downloads
Copyright: Commercial use requires permission


Size: 18,457 bytes
Updated on Sun, 07 Apr 2002 17:23:44 GMT
Originally uploaded on Mon, 11 Mar 2002 22:30:24 GMT
SHA1 Hash: 4ECBB803DC70C0160F1B75E6EEAFF4EEEAB5A8AD
MD5 Hash: C96E9995243E97D680CEF0C5F5578016

    Explore the files in this upload

Description
I needed to count the number of records exported to a series of CSV files so CountCR was born.

It simply uses a number of threads managed in a pool to count the CR's in a list of files. It includes an Abort button to stop the count should you need to - some of the exported CSV's that I count have over 2 million records.

The threads are kept in a pool and a task is created for each file that needs to be counted. The tasks are stored in a ThreadList. Each thread in the pool takes the next task on the list and processes it before looking for another task. Signalling to waiting threads is handled by a TEvent and the GUI is updated with Synchronize calls.

The TThreadPool, TPooledThread and the abstract TCustomTask form the core of the application. TStreamCountTask is descended from TCustomTask and implements the actual counting code. Different tasks can be accomodated by making a descendant of TCustomTask and writing the appropriate OnThreadUpdate event code. Instances of the new Task are then added to the ThreadPool.

TThreadPool is now a component. The demo program however still manually creates the TThreadPool so that the component does not need to be installed. Package source is included for those who want it.

Contest entry forMultithreaded programming

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC04