c# - Speed up console application, Concurrency? Parralell Programming? -
i have following (simplified) console application:
directoryinfo d = new directoryinfo(@"d:\test"); fileinfo[] files = d.getfiles("*.txt"); foreach(fileinfo file in files ) { //do }
there 200+ files in filefolder. processing of each file take 15 minutes.
my question is, possible me use concurrency/parallel programming process more on file @ time?
the kind of thing thinking is, start number of threads? , each 1 of them process every 5th or file in files list.
all file processing totally independent, no risk of race condition.
if possible, there limits how many threads can start, or other limitations.
the kind of work done load contents of each file generic list, process , iterate through list numerous times
it seems it's job parallel.foreach
. provide true parallelization because can schedule each iteration different cpu core.
if possible, there limits how many threads can start, or other limitations.
i wouldn't spawn hundred of threads perform job, because might happen handling lot of threads can take more time because cpu , disk busy.
Comments
Post a Comment