/// <summary> /// Begins reading period terminated data from source stream. Reads data while gets single period on line, /// what is data terminator. /// </summary> /// <param name="storeStream">Stream where to store data.</param> /// <param name="maxSize">Maximum muber of bytes to read.</param> /// <param name="exceededAction">Specifies how this method behaves when maximum size exceeded.</param> /// <param name="callback">Callback to be called if asynchronous reading completes.</param> /// <param name="tag">User data.</param> /// <exception cref="ArgumentNullException">Raised when <b>storeStream</b> is null.</exception> /// <exception cref="InvalidOperationException">Raised when there already is pending read operation.</exception> public void BeginReadPeriodTerminated(Stream storeStream,int maxSize,SizeExceededAction exceededAction,ReadToStreamCallback callback,object tag) { if(storeStream == null){ throw new ArgumentNullException("storeStream"); } lock(this){ if(m_IsReadActive){ throw new InvalidOperationException("There is pending read operation, multiple read operations not allowed !"); } m_IsReadActive = false; } _ToStreamReader reader = new _ToStreamReader(this,storeStream,maxSize,exceededAction,callback,tag); reader.BeginReadPeriodTerminated(); }
/// <summary> /// Starts reading specified amount data and storing to the specified store stream. /// </summary> /// <param name="storeStream">Stream where to store readed data.</param> /// <param name="count">Number of bytes to read from source stream and write to store stream.</param> /// <param name="callback">Callback to be called if asynchronous reading completes.</param> /// <param name="tag">User data.</param> /// <exception cref="ArgumentNullException">Raised when <b>storeStream</b> is null.</exception> /// <exception cref="ArgumentException">Raised when <b>count</b> less than 1.</exception> public void BeginRead(Stream storeStream,int count,ReadToStreamCallback callback,object tag) { if(storeStream == null){ throw new ArgumentNullException("storeStream"); } if(count < 1){ throw new ArgumentException("Parameter count value must be >= 1 !"); } lock(this){ if(m_IsReadActive){ throw new InvalidOperationException("There is pending read operation, multiple read operations not allowed !"); } m_IsReadActive = true; } _ToStreamReader reader = new _ToStreamReader(this,storeStream,0,SizeExceededAction.ThrowException,callback,tag); reader.BeginRead(count); }