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 of AsyncStreaming.
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 from BaseAsyncStreamReader class and adds constructors.
Public methods:
StartRead() - Starts an asynchronous read operation
PauseRead() – Pause an asynchronous read operation
ResumeRead() – Resume a paused asynchronous read operation
StopRead() – Stops an asynchronous read operation
Events:
OnReadedBytes – Occurs when the progress is increased by one percent
OnEndRead – Occurs when all the bytes are read
OnError – Occurs when an AsyncStreamExcpetion happens
OnStateChanged – Occurs when state of AsyncStreamReader is changed
Constructor:
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 from BaseAsyncStreamWriter class and adds constructors.
Public methods:
StartWrite() – Begins an asynchronous write operation
PauseWrite() – Pauses an asynchronous write operation
ResumeWrite() – Resumes a paused asynchronous write operation
StopWrite() – Stops an asynchronous write operation
Events:
OnStateChanged – Occurs when state of AsyncStreamWriter is changed
OnWritedBytes – Occurs when the progress is increased by one percent
OnEndWrite – Occurs when all bytes are written
OnError - Occurs when an AsyncException happens
Constructors:
public AsyncStreamWriter()
public AsyncStreamWriter(string outputPath)
public AsyncStreamWriter(string outputPath, string buffer, Encoding encoding)
public AsyncStreamWriter(string outputPath, string buffer)
public AsyncStreamWriter(string outputPath, byte[] buffer)
History
- 21st April, 2009: Initial post