/// <summary>sends IDLE command</summary>
        /// <remarks>valid in authenticated/selected state</remarks>
        public IAsyncResult BeginIdle(object keepIdleState, ImapKeepIdleCallback keepIdleCallback)
        {
            IdleTransaction t = null;

              try {
            RejectNonAuthenticatedState();
            RejectIdling();

            t = new IdleTransaction(connection, keepIdleState, keepIdleCallback);

            var asyncResult = BeginProcessTransaction(t, handlesIncapableAsException);

            // wait for IDLE started or respond tagged error response
            t.WaitForIdleStateChanged();

            return asyncResult;
              }
              catch {
            if (t != null) {
              t.Dispose();
              t = null;
            }

            throw;
              }
        }
        private ImapCommandResult IdleInternal(int idleMillisecondsTimeout, object keepIdleState, ImapKeepIdleCallback keepIdleCallback)
        {
            if (idleMillisecondsTimeout < -1)
            throw new ArgumentOutOfRangeException("idleMillisecondsTimeout", idleMillisecondsTimeout, "must be greater than or equals to -1");

              var idleAsyncResult = BeginIdle(keepIdleState, keepIdleCallback);

              idleAsyncResult.AsyncWaitHandle.WaitOne(idleMillisecondsTimeout, false);

              return EndIdle(idleAsyncResult);
        }
        public ImapCommandResult Idle(int idleMillisecondsTimeout, object state, ImapKeepIdleCallback keepIdleCallback)
        {
            if (keepIdleCallback == null)
            throw new ArgumentNullException("keepIdleCallback");

              return IdleInternal(idleMillisecondsTimeout, state, keepIdleCallback);
        }
 public ImapCommandResult Idle(TimeSpan idleTimeout, object state, ImapKeepIdleCallback keepIdleCallback)
 {
     return Idle((int)idleTimeout.TotalMilliseconds, state, keepIdleCallback);
 }
 public ImapCommandResult Idle(object state, ImapKeepIdleCallback keepIdleCallback)
 {
     return Idle(Timeout.Infinite, state, keepIdleCallback);
 }
Ejemplo n.º 6
0
 public IdleTransaction(ImapConnection connection, object keepIdleState, ImapKeepIdleCallback keepIdleCallback)
     : base(connection)
 {
     this.keepIdleState = keepIdleState;
       this.keepIdleCallback = keepIdleCallback;
 }