/// <summary> /// Starts sending NOOP command to server. This method can be used for keeping connection alive(not timing out). /// </summary> /// <param name="callback">Callback to call when the asynchronous operation is complete.</param> /// <param name="state">User data.</param> /// <returns>An IAsyncResult that references the asynchronous operation.</returns> /// <exception cref="ObjectDisposedException">Is raised when this object is disposed and this method is accessed.</exception> /// <exception cref="InvalidOperationException">Is raised when POP3 client is not connected.</exception> public IAsyncResult BeginNoop(AsyncCallback callback, object state) { if (IsDisposed) { throw new ObjectDisposedException(GetType().Name); } if (!IsConnected) { throw new InvalidOperationException("You must connect first."); } NoopDelegate asyncMethod = Noop; AsyncResultState asyncState = new AsyncResultState(this, asyncMethod, callback, state); asyncState.SetAsyncResult(asyncMethod.BeginInvoke(asyncState.CompletedCallback, null)); return(asyncState); }
public IAsyncResult BeginNoop(AsyncCallback callback,object state) { if(this.IsDisposed){ throw new ObjectDisposedException(this.GetType().Name); } if(!this.IsConnected){ throw new InvalidOperationException("You must connect first."); } NoopDelegate asyncMethod = new NoopDelegate(this.Noop); AsyncResultState asyncState = new AsyncResultState(this,asyncMethod,callback,state); asyncState.SetAsyncResult(asyncMethod.BeginInvoke(new AsyncCallback(asyncState.CompletedCallback),null)); return asyncState; }