internal IAsyncResult BeginExecute(int timeout, Stream userStream, string file, long offset, long length, AsyncCallback cb, object state) { GetFile_SO stateObj = null; SetProgress(true); try { CreateDTP(); stateObj = new GetFile_SO(userStream, cb, state); string cmd = "RETR " + file; _currentDTP.BeginExecute(timeout, cmd, _client.DataType, offset, new DTPStreamCommon(userStream, DTPStreamType.ForWriting, length), new AsyncCallback(this.RunDTP_End), stateObj); } catch { SetProgress(false); CheckDisposed(); throw; } return(stateObj); }
void RunDTP_End(IAsyncResult ar) { GetFile_SO stateObj = (GetFile_SO)ar.AsyncState; try { stateObj.UpdateContext(); _currentDTP.EndExecute(ar); } catch (Exception e) { stateObj.Exception = e; } catch { NSTrace.WriteLineError("Non-CLS exception at: " + Environment.StackTrace); throw; } stateObj.SetCompleted(); }