Asynchronous Stream Reader and Writer with Progress Support
AsyncStreaming

Introduction
AsyncStreaming
is a class library for asynchronous stream reading and writing. AsyncStreaming
supports progress on reading and writing.
Structure
Common classes that use both AsynStreamReader
and AsyncStreamWriter
:
AsyncStreamException
- This class represent errors that occur during asynchronous streaming.AsyncStreamStateChangeArgs
- This class provides data for the on state change event.AsyncStreamErrorEventArgs
- This class provides data for the on error event.AsyncStreamState
- This enumeration specifies identifiers to indicate the state ofAsyncStreaming
.
Possible states:
- None
- Ready - This state occurs when stream is ready to start.
- Started - This state occurs when stream is started.
- Paused - This state occurs when stream is paused.
- Stopped - This state occurs when stream is stopped.
- Finished - This state occurs when stream is finished.
- Error - This state occurs when a stream exception has happened.
AsyncStreamReader

BaseAsyncStreamReader
- Base functionality for asynchronous reading. So you can easily use this class to implement base functionality in your own reading class.AsyncStreamReader
- Class that extends fromBaseAsyncStreamReader
class and adds constructors.
Public
methods:
StartRead()
- Starts an asynchronous read operationPauseRead()
– Pause an asynchronous read operationResumeRead()
– Resume a paused asynchronous read operationStopRead()
– Stops an asynchronous read operation
Events:
OnReadedBytes
– Occurs when the progress is increased by one percentOnEndRead
– Occurs when all the bytes are readOnError
– Occurs when anAsyncStreamExcpetion
happensOnStateChanged
– Occurs when state ofAsyncStreamReader
is changed
Constructor:
/// <summary>
/// Implements a System.IO.TextReader that reads characters from a byte stream
/// in a particular encoding.
/// </summary>
/// <param name="path">The complete file path to be read.</param>
public AsyncStreamReader(string path)
AsyncStreamWriter

BaseAsyncStreamWriter
– Base functionality for asynchronous writing. So you can easily use this class to implement base functionality in your own writing class.AsyncStreamWriter
– Class that extends fromBaseAsyncStreamWriter
class and adds constructors.
Public
methods:
StartWrite()
– Begins an asynchronous write operationPauseWrite()
– Pauses an asynchronous write operationResumeWrite()
– Resumes a paused asynchronous write operationStopWrite()
– Stops an asynchronous write operation
Events:
OnStateChanged
– Occurs when state ofAsyncStreamWriter
is changedOnWritedBytes
– Occurs when the progress is increased by one percentOnEndWrite
– Occurs when all bytes are writtenOnError
- Occurs when anAsyncException
happens
Constructors:
/// <summary>
/// Initializes a new empty instance of the AsyncStreaming.AsyncStreamWriter class.
/// </summary>
public AsyncStreamWriter()
/// <summary>
/// Initializes a new instance of the AsyncStreaming.AsyncStreamWriter
/// class for the specified
/// file on the specified path, using the default encoding.
/// </summary>
/// <param name="outputPath">The complete file path to write to.
/// Path can be a file name.</param>
public AsyncStreamWriter(string outputPath)
/// <summary>
/// Initializes a new instance of the AsyncStreaming.AsyncStreamWriter
/// class for the specified
/// file on the specified path, using the default encoding.
/// </summary>
/// <param name="outputPath">The complete file path to write to.
/// Path can be a file name.</param>
/// <param name="buffer">The string to write to the stream.
/// If value is null, nothing is written.</param>
/// <param name="encoding">The string encoding to use.</param>
public AsyncStreamWriter(string outputPath, string buffer, Encoding encoding)
/// <summary>
/// Initializes a new instance of the AsyncStreaming.AsyncStreamWriter
/// class for the specified
/// file on the specified path, using the default encoding.
/// </summary>
/// <param name="outputPath">The complete file path to write to.
/// Path can be a file name.</param>
/// <param name="buffer">The string to write to the stream.
/// If value is null, nothing is written.</param>
public AsyncStreamWriter(string outputPath, string buffer)
/// <summary>
/// Initializes a new instance of the AsyncStreaming.AsyncStreamWriter
/// class for the specified
/// file on the specified path, using the default encoding.
/// </summary>
/// <param name="outputPath">The complete file path to write to.
/// Path can be a file name.</param>
/// <param name="buffer">An array of bytes.
/// This method copies count bytes from buffer to the current stream.</param>
public AsyncStreamWriter(string outputPath, byte[] buffer)
History
- 21st April, 2009: Initial post