Will using multiple threads speed up my HTML file processing application?

I just finished my most complex and functionally loaded WinForms application . It loads the list into any number of HTML files, then downloads the contents of one, uses some RegEx to match some tags, and removes or replaces them (yes, yes, I saw this. This works fine, thanks to Cthul), and then writes it to disk.

However, I noticed that ~ 200 files take about 30 seconds to process, and after the first 5-10 seconds the program says "Do not respond." I suppose it's not good to do something like this guy , since the hard drive is the bottleneck.

Perhaps it will be possible to load as much as possible into memory, and then process each of them with a stream, write them, and then load a little more into memory?

At the very least, creating a workflow separate from the user interface thread will prevent the Do Not Respond problem? ( This MSDN article covers what I was considering. )

I’m probably asking if multithreading will offer any speed improvements, and if so, what would be the best way to do this?

Any help or advice is greatly appreciated!

+3
source share
5 answers

, Backgroundworker, GUI. . 20 , 20 .

, ( ) TPL.

, , .

+3

, .., , . - (). , IO. 1 2 , .

+2

, , , ( ).

, , .

, P , P . ( )

BackgroundWorker .: # BackgroundWorker Tutorial

+2

StreamReader.ReadAllLines() , ?

0

If you do all your processing in a GUI thread, your application will show "not responding" if it takes a very long time. In my opinion, you should try never to perform (extensive) processing of actions in the same thread as your GUI. In addition, you can even create a stream for each file being processed. This will most of all speed up the work until the individual threads do not need any data from each other.

-1
source

All Articles