//取得する行のオフセット、取得する行数、ステップを指定 public async Task <string[]> GetLines(long offset, long num, long step = 1) { var start = Math.Max(0, offset); var end = offset + num * step - 1; step = Math.Max(step, 1); var result = new List <string>(); await Task.Run(() => { var info = Info; if (info != null) { end = Math.Min(end, info.TotalLineNUM - 1); if (start >= end) { return; } var list = new ConcurrentBag <DividedFile>(); var fileNUM = info.FileNames.Count; Parallel.For( 0, fileNUM, i => { var fileStart = (info.MaxLineNUM *i); var fileEnd = Math.Min(fileStart + info.MaxLineNUM - 1, end); var lineNUM = (long)(fileEnd - fileStart); if (fileEnd >= start && lineNUM > 0) { var dividedFile = new DividedFile(i); var filePath = Path.Combine(InfoFileDirectory, info.FileNames[i]); dividedFile.Load(filePath, fileStart, start, fileEnd, step); list.Add(dividedFile); } } ); if (list.Count > 0) { var array = list.OrderBy(e => e.Id).ToArray(); foreach (var file in array) { foreach (var line in file.Lines) { result.Add(line); } } } } }); return(result.ToArray()); }