예제 #1
0
        private void Downloader_DownloadCompleted(object sender, System.EventArgs e)
        {
            QueueElementCompleted?.Invoke(this, new QueueElementCompletedEventArgs(CurrentIndex, _currentElement));
            for (var i = 0; i < _elements.Count; i++)
            {
                if (_elements[i].Equals(_currentElement))
                {
                    _elements[i] = new HttpDownloadQueueElement
                    {
                        Id          = _elements[i].Id,
                        Url         = _elements[i].Url,
                        Destination = _elements[i].Destination,
                        Completed   = true
                    };
                    break;
                }
            }

            CreateNextDownload();
        }
예제 #2
0
        private void Downloader_DownloadError(object sender, System.EventArgs e)
        {
            QueueElementCompleted?.Invoke(this, new QueueElementCompletedEventArgs(CurrentIndex, _currentElement));
            for (var i = 0; i < _elements.Count; i++)
            {
                if (_elements[i].Equals(_currentElement))
                {
                    _elements[i] = new HttpDownloadQueueElement
                    {
                        Id          = _elements[i].Id,
                        Url         = _elements[i].Url,
                        Destination = _elements[i].Destination,
                        Completed   = true
                    };
                    break;
                }
            }

            var active = Form.ActiveForm;

            if (active != null && active.InvokeRequired)
            {
                active.BeginInvoke((MethodInvoker) delegate
                {
                    MessageBox.Show("Download error occurred. Please check your connection, and that the content requested is available for download.",
                                    "Download Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                });
            }
            else
            {
                MessageBox.Show("Download error occurred. Please check your connection, and that the content requested is available for download.",
                                "Download Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            QueueCompleted?.Invoke(this, new System.EventArgs());
        }