Visual Basic (Declaration) | |
---|---|
Public Function Read( _ ByVal position As Long, _ ByVal buffer() As Byte, _ ByVal offset As Integer, _ ByVal length As Integer _ ) As Integer |
Parameters
- position
- buffer
- offset
- length
Library/Library.Test/TestBackgroundWriter.cs
C# | Copy Code |
---|---|
using (TestStream io = new TestStream()) using (BackgroundWriter wtr = new BackgroundWriter(io)) { wtr.Write(0L, new byte[100], 0, 100); wtr.Perform(s => Thread.Sleep(50)); wtr.Write(100L, new byte[] { 99 }, 0, 1); wtr.Write(100L, new byte[] { 42, 43 }, 0, 2); // Read scans the pending writes for writes at the provided offset and returns the last result byte[] read = new byte[100]; Assert.AreEqual(2, wtr.Read(100L, read, 0, 100)); Assert.AreEqual(42, (int)read[0]); Assert.AreEqual(43, (int)read[1]); } |
VB.NET | Copy Code |
---|---|
Using io As New TestStream() Using wtr As New BackgroundWriter(io) wtr.Write(0L, New Byte(100) {}, 0, 100) wtr.Perform(Function(s) Thread.Sleep(50)) wtr.Write(100L, New Byte() {99}, 0, 1) wtr.Write(100L, New Byte() {42, 43}, 0, 2) ' Read scans the pending writes for writes at the provided offset and returns the last result Dim read As Byte() = New Byte(100) {} Assert.AreEqual(2, wtr.Read(100L, read, 0, 100)) Assert.AreEqual(42, DirectCast(read(0), Integer)) Assert.AreEqual(43, DirectCast(read(1), Integer)) End Using End Using |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7