Class SyncMemoryStream
- Namespace
- Microsoft.WindowsAzure.Storage.Core
- Assembly
- Microsoft.WindowsAzure.Storage.dll
This class provides APM Read/Write overrides for memory stream to improve performance.
public class SyncMemoryStream : MemoryStream, IDisposable, IAsyncDisposable
- Inheritance
-
SyncMemoryStream
- Implements
- Inherited Members
Constructors
SyncMemoryStream()
Initializes a new instance of the SyncMemoryStream class with an expandable capacity initialized to zero.
public SyncMemoryStream()
SyncMemoryStream(byte[])
Initializes a new non-resizable instance of the SyncMemoryStream class based on the specified byte array.
public SyncMemoryStream(byte[] buffer)
Parameters
buffer
byte[]The array of unsigned bytes from which to create the current stream.
SyncMemoryStream(byte[], int)
Initializes a new non-resizable instance of the SyncMemoryStream class based on the specified region (index) of a byte array.
public SyncMemoryStream(byte[] buffer, int index)
Parameters
buffer
byte[]The array of unsigned bytes from which to create the current stream.
index
intThe index into buffer at which the stream begins.
SyncMemoryStream(byte[], int, int)
Initializes a new non-resizable instance of the SyncMemoryStream class based on the specified region (index) of a byte array.
public SyncMemoryStream(byte[] buffer, int index, int count)
Parameters
buffer
byte[]The array of unsigned bytes from which to create the current stream.
index
intThe index into buffer at which the stream begins.
count
intThe length of the stream in bytes.
Methods
BeginRead(byte[], int, int, AsyncCallback, object)
Begins an asynchronous read operation.
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
Parameters
buffer
byte[]When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
offset
intThe zero-based byte offset in buffer at which to begin storing the data read from the current stream.
count
intThe maximum number of bytes to be read.
callback
AsyncCallbackAn optional asynchronous callback, to be called when the read is complete.
state
objectA user-provided object that distinguishes this particular asynchronous read request from other requests.
Returns
- IAsyncResult
An IAsyncResult that represents the asynchronous read, which could still be pending.
BeginWrite(byte[], int, int, AsyncCallback, object)
Begins an asynchronous write operation.
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
Parameters
buffer
byte[]The buffer to write data from.
offset
intThe zero-based byte offset in buffer at which to begin copying bytes to the current stream.
count
intThe number of bytes to write.
callback
AsyncCallbackAn optional asynchronous callback, to be called when the write is complete.
state
objectA user-provided object that distinguishes this particular asynchronous write request from other requests.
Returns
- IAsyncResult
An IAsyncResult that represents the asynchronous write, which could still be pending.
EndRead(IAsyncResult)
Waits for the pending asynchronous read to complete.
public override int EndRead(IAsyncResult asyncResult)
Parameters
asyncResult
IAsyncResultThe reference to the pending asynchronous request to finish.
Returns
- int
The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream has been reached.
EndWrite(IAsyncResult)
Ends an asynchronous write operation.
public override void EndWrite(IAsyncResult asyncResult)
Parameters
asyncResult
IAsyncResultThe reference to the pending asynchronous request to finish.