private void StartSegments(int segmentCount, Stream inputStream) { // notifies OnInfoReceived(); // allocs the file on disk AllocLocalFile(); if (this.segments.Count == 0) { long segmentSize; CalculatedSegment[] calculatedSegments; if (!remoteFileInfo.AcceptRanges) { calculatedSegments = new CalculatedSegment[] { new CalculatedSegment(0, remoteFileInfo.FileSize) }; } else { calculatedSegments = this.SegmentCalculator.GetSegments(segmentCount, remoteFileInfo); } lock (threads) threads.Clear(); lock (segments) segments.Clear(); for (int i = 0; i < calculatedSegments.Length; i++) { Segment segment = new Segment(); if (i == 0) { segment.InputStream = inputStream; } segment.Index = i; segment.InitialStartPosition = calculatedSegments[i].StartPosition; segment.StartPosition = calculatedSegments[i].StartPosition; segment.EndPosition = calculatedSegments[i].EndPosition; segments.Add(segment); } } RunSegments(); }
private void StartSegments(int segmentCount, Stream inputStream) { // notifies OnInfoReceived(); // allocs the file on disk AllocLocalFile(); long segmentSize; CalculatedSegment[] calculatedSegments; if (!remoteFileInfo.AcceptRanges) { calculatedSegments = new CalculatedSegment[] { new CalculatedSegment(0, remoteFileInfo.FileSize) }; } else { calculatedSegments = this.SegmentCalculator.GetSegments(segmentCount, remoteFileInfo); } lock (threads) threads.Clear(); lock (segments) segments.Clear(); for (int i = 0; i < calculatedSegments.Length; i++) { Segment segment = new Segment(); if (i == 0) { segment.InputStream = inputStream; } segment.Index = i; segment.InitialStartPosition = calculatedSegments[i].StartPosition; segment.StartPosition = calculatedSegments[i].StartPosition; segment.EndPosition = calculatedSegments[i].EndPosition; segments.Add(segment); } RunSegments(); }