IAsyncResult BeginRunDownloadingStream(DTPStream userStream, AsyncCallback cb, object state) { TransStateObjectStream stateObj = new TransStateObjectStream(userStream, cb, state); DataStream.BeginRead(_workBuffer, 0, _workBuffer.Length, new AsyncCallback(this.DataStreamRead_End), stateObj); return(stateObj); }
void UserStreamWrite_End(IAsyncResult ar) { TransStateObjectStream stateObj = (TransStateObjectStream)ar.AsyncState; try { stateObj.UpdateContext(); DTPStream userStream = (DTPStream)stateObj.UserStream; userStream.EndWrite(ar); if (_aborted) { throw new FtpAbortedException(); } if (userStream.AvailableSpace > 0) { DataStream.BeginRead(_workBuffer, 0, _workBuffer.Length, new AsyncCallback(this.DataStreamRead_End), stateObj); } else { _manuallyClosed = true; userStream.Flush(); OnCompleted(); stateObj.SetCompleted(); } } catch (Exception e) { stateObj.Exception = e; stateObj.SetCompleted(); } catch { NSTrace.WriteLineError("Non-CLS exception at: " + Environment.StackTrace); throw; } }
private void onFlushed() { _data.BeginRead(_client.Buffer.Storage, onDataAvailable); }