public void ViaSocketWriter() { var ranges = new RangeCollection(); var fileStream = new FileStream(@"C:\Users\jgauffin\Downloads\AspNetMVC3ToolsUpdateSetup.exe", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); ranges.Parse("bytes=0-50000", (int)fileStream.Length); var stream = new ByteRangeStream(ranges, fileStream); var job = new StreamSocketWriterJob(stream); var buffer = new byte[65535]; var args = Substitute.For <SocketAsyncEventArgs>(); args.UserToken.Returns(buffer); job.Write(args); while (true) { if (job.WriteCompleted(5000)) { job.Dispose(); break; } job.Write(args); } }
public void ViaSocketWriter() { var ranges = new RangeCollection(); var fileStream = new FileStream(@"C:\Users\jgauffin\Downloads\AspNetMVC3ToolsUpdateSetup.exe", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); ranges.Parse("bytes=0-50000", (int)fileStream.Length); var stream = new ByteRangeStream(ranges, fileStream); var job = new StreamSocketWriterJob(stream); var buffer = new byte[65535]; var args = Substitute.For<SocketAsyncEventArgs>(); args.UserToken.Returns(buffer); job.Write(args); while (true) { if (job.WriteCompleted(5000)) { job.Dispose(); break; } job.Write(args); } }