/// <summary> /// Starts switching to SSL. /// </summary> /// <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 or is authenticated or is already secure connection.</exception> public IAsyncResult BeginStartTLS(AsyncCallback callback, object state) { if (IsDisposed) { throw new ObjectDisposedException(GetType().Name); } if (!IsConnected) { throw new InvalidOperationException("You must connect first."); } if (IsAuthenticated) { throw new InvalidOperationException( "The STLS command is only valid in non-authenticated state."); } if (IsSecureConnection) { throw new InvalidOperationException("Connection is already secure."); } StartTLSDelegate asyncMethod = StartTLS; AsyncResultState asyncState = new AsyncResultState(this, asyncMethod, callback, state); asyncState.SetAsyncResult(asyncMethod.BeginInvoke(asyncState.CompletedCallback, null)); return(asyncState); }
public IAsyncResult BeginStartTLS(AsyncCallback callback,object state) { if(this.IsDisposed){ throw new ObjectDisposedException(this.GetType().Name); } if(!this.IsConnected){ throw new InvalidOperationException("You must connect first."); } if(this.IsSecureConnection){ throw new InvalidOperationException("Connection is already secure."); } StartTLSDelegate asyncMethod = new StartTLSDelegate(this.StartTLS); AsyncResultState asyncState = new AsyncResultState(this,asyncMethod,callback,state); asyncState.SetAsyncResult(asyncMethod.BeginInvoke(new AsyncCallback(asyncState.CompletedCallback),null)); return asyncState; }