Exemple #1
0
        private void PerformAction(IMailClient client, IEnumerable <int> mailIndexes, string mailbox)
        {
            int cnt = 0;

            foreach (var mailIndex in mailIndexes)
            {
                ListViewItem item = null;

                var parser = client.FetchMailFromHeader(mailIndex, mailbox);
                item = new ListViewItem(parser.From.ToString());
                item.SubItems.Add(parser.Subject);
                item.SubItems.Add(parser.Headers["Date"]);
                item.Tag = client;

                //System.Threading.Thread.Sleep(50);
                action?.Invoke(this, new ActionEventArgs()
                {
                    Item = item
                });
                //UpdateProgressBar(pBar, mailIndexes.Count(), ++cnt);
                _progressValueChangedEventHandler?.Invoke(this, new ProgressValueChangeEventArgs()
                {
                    MinValue = 0, MaxValue = Math.Min(mailIndexes.Count(), MailCount) - 1, Value = cnt++
                });
                if (MailCount > 0 && cnt == MailCount)
                {
                    break;
                }
            }
        }
        private void PerformAction(IMailClient client, IEnumerable<int> mailIndexes)
        {
            int cnt = 0;

            foreach (var mailIndex in mailIndexes)
            {
                ListViewItem item = null;

                var parser = client.FetchMailFromHeader(mailIndex);
                item = new ListViewItem(parser.From.ToString());
                item.SubItems.Add(parser.Subject);
                item.SubItems.Add(parser.Headers["Date"]);
                item.Tag = client;

                //System.Threading.Thread.Sleep(50);
                if (this.action != null)
                    this.action(this, new ActionEventArgs() { Item = item });
                //UpdateProgressBar(pBar, mailIndexes.Count(), ++cnt);
                if (this._progressValueChangedEventHandler != null)
                    this._progressValueChangedEventHandler(this, new ProgressValueChangeEventArgs() { MinValue = 0, MaxValue = mailIndexes.Count(), Value = cnt++ });
                if (MailCount > 0 && cnt == MailCount)
                    break;
            }
        }