How is it possible to multi-threaded to read the file in chunks, that is, the first stream reads, for example, the first 100 lines (lines = long), the second reads further 150 lines, and then again the first one reads further 50 lines after 250 lines (100 and 150). .. there is a thread option how to implement the algorithm? Okay, it's not a problem to assume .... the problem is to go back to the first thread and to count further lines that start after the second stream.

  • one
    working with files is not parallel, or rather it does not make sense, because disk is a sequential access device regardless of mechanics or ssd / flash, sata / sas or ide / scsi, its interface logic is sequential. If you really want to, open the file for reading without blocking, and read the same in different streams, each of its stream, only it does not add speed, rather the opposite - rdorn
  • one
    better describe what you want to achieve with such a decision, maybe there is something else. - rdorn
  • @rdorn is the one I can implement, everything is simple there, but what I wrote is more complicated, probably ---- e, well, I entered something from Claudia and let the computer search for a multi-threaded string in an array like that .. - user240095
  • so in an array or file? - rdorn
  • file as an array, of type string [] file = File.ReadAlllLines (@ "\\ *. txt"); - user240095

1 answer 1

var lines_number = 100; var stroki = File.ReadLines(@"D:\data.txt").Take(lines_number).ToArray();