Example #1
0
        public virtual void OnPageDownloadComplete(PageDownloadCompleteEventArgs e)
        {
            if (PageDownloadComplete != null)
            {
                Delegate[] delArray = PageDownloadComplete.GetInvocationList();

                foreach (Delegate del in delArray)
                {
                    PageDownloadCompleteHandler method = (PageDownloadCompleteHandler)del;
                    method.BeginInvoke(this, e, null, null);
                }
            }
        }
Example #2
0
        // 批量下载所有的page的内容
        public bool DownloadPageContent(CancellationToken ct)
        {
            XPCollection<Page> pages = new XPCollection<Page>(XpoDefault.Session, CriteriaOperator.Parse("Is_Down = ?", false));
            foreach(Page p in pages)
            {
                if (ct.IsCancellationRequested)
                {
                    OnAllPageDownloadComplete(new EventArgs());     // 通知下载结束
                    return false;       // 被取消后的退出
                }
                else
                {
                    p.ParentWeb.Rule.GetPageContent(p);

                    // 发出下载完成事件
                    PageDownloadCompleteEventArgs e = new PageDownloadCompleteEventArgs(p);
                    OnPageDownloadComplete(e);
                }
            }
            OnAllPageDownloadComplete(new EventArgs());     // 通知下载结束
            return true;            // 下载完成后退出
        }