Example #1
0
        private void ProcessIdleServerEvents()
        {
            while (true)
            {
                if (_idleEvents.Count == 0)
                {
                    if (_idleState == IdleState.On)
                    {
                        continue;
                    }
                    else
                    {
                        return;
                    }
                }

                var tmp = _idleEvents.Dequeue();
                var match = Expressions.IdleResponseRex.Match(tmp);

                if (!match.Success)
                {
                    continue;
                }

                if (match.Groups[2].Value == "EXISTS")
                {
                    SelectedFolder.Status(new[] { FolderStatusFields.UIdNext });

                    if (_lastIdleUId != SelectedFolder.UidNext)
                    {
                        var msgs = SelectedFolder.Search(string.Format("UID {0}:{1}", _lastIdleUId, SelectedFolder.UidNext));
                        var args = new IdleEventArgs
                        {
                            Folder = SelectedFolder,
                            Messages = msgs
                        };

                        if (OnNewMessagesArrived != null)
                        {
                            OnNewMessagesArrived(SelectedFolder, args);
                        }

                        SelectedFolder.RaiseNewMessagesArrived(args);
                        _lastIdleUId = SelectedFolder.UidNext;
                    }
                }
            }
        }
Example #2
0
        internal void RaiseNewMessagesArrived(IdleEventArgs args)
        {
            if (OnNewMessagesArrived == null)
            {
                return;
            }

            OnNewMessagesArrived(this, args);
        }