コード例 #1
0
        public ImapMessageInfoList EndWaitForMessageArrival(IAsyncResult asyncResult)
        {
            if (asyncResult != waitForMessageArrivalAsyncResult)
            throw new ArgumentException("invalid IAsyncResult", "asyncResult");

              try {
            waitForMessageArrivalAsyncResult.EndProc();

            return GetArrivalMessages(waitForMessageArrivalAsyncResult);
              }
              finally {
            waitForMessageArrivalAsyncResult = null;
              }
        }
コード例 #2
0
        public IAsyncResult BeginWaitForMessageArrival(int millisecondsPollingInterval,
                                                   ImapMessageFetchAttributeOptions options,
                                                   object asyncState,
                                                   AsyncCallback asyncCallback)
        {
            if (millisecondsPollingInterval <= 0)
            throw new ArgumentOutOfRangeException("millisecondsPollingInterval", millisecondsPollingInterval, "must be non-zero positive number");
              if (waitForMessageArrivalAsyncResult != null)
            throw new InvalidOperationException("another operation proceeding");

              var isIdleCapable = Client.ServerCapabilities.Has(ImapCapability.Idle);

              if (!isIdleCapable && maximumPollingInterval <= millisecondsPollingInterval)
            throw new ArgumentOutOfRangeException("millisecondsPollingInterval",
                                              millisecondsPollingInterval,
                                              string.Format("maximum interval is {0} but requested was {1}", maximumPollingInterval, millisecondsPollingInterval));

              var proc = isIdleCapable
            ? new WaitForMessageArrivalProc(WaitForMessageArrivalIdle)
            : new WaitForMessageArrivalProc(WaitForMessageArrivalNoOp);

              waitForMessageArrivalAsyncResult = new WaitForMessageArrivalAsyncResult(millisecondsPollingInterval,
                                                                              Mailbox,
                                                                              options,
                                                                              proc,
                                                                              asyncState,
                                                                              asyncCallback);

              waitForMessageArrivalAsyncResult.BeginProc();

              return waitForMessageArrivalAsyncResult;
        }