Multithreading a Console Application

The FileSort application is a utility application that sorts the contents of text files. The intent is that the text files contain fixed-length records, each record represented by a line of text, and we want to sort the lines of text by some subfields in the line of text. Perhaps the text file is an exported table from a legacy database.

The example presumes that there might be very large and very small files and some further processing—like loading the rows into a relational database—will be performed on the data. To ensure that shorter files do not get stuck behind longer files, we elected to allow the user to specify several files on the command line and thread the sort process. Each file is sorted on its ...

Get Visual Basic® .NET Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.