Ejemplo n.º 1
0
        /// <summary>
        /// 获取单个画师,只能由DoGetThread执行
        /// </summary>
        /// <param name="listUrl">画师作品列表页</param>
        protected void GetSingle(object objParame)
        {
            try
            {
                if (!Mut.IsContinue)
                {
                    return;
                }

                //因为循环里没有做修改,所有可以放外面
                var parame = (RequestParameEntity)objParame;

                MyForm.BeginInvoke(new Action(() => { MyForm.RtxtSuccess.Text = ""; }));

                if (IsSingle)
                {
                    MyForm.Invoke(new Action(() => { MyForm.TxtSavePath.Text = parame.SavePath; }));
                }

                EachListPage(parame.ListUrl, DownContentType.SinglePainter, new Action <string>(itemUrl =>
                {
                    if (!Mut.IsContinue)
                    {
                        return;
                    }

                    itemUrl = HtmlHelp.NeedHost(parame.ListUrl, itemUrl);

                    var ri = new RequestItemParameEntity()
                    {
                        ItemUrl = itemUrl, SavePath = parame.SavePath
                    };

                    if (IsSingle)
                    {
                        GetWorksItem(ri);
                    }
                    else
                    {
                        while (!Mut.DoDownAction(ri, GetWorksItem) && Mut.IsContinue)
                        {
                            Thread.Sleep(1000);
                        }
                    }
                }));
            }
            catch (Exception ex)
            {
                AddErrorMsg(ex.Message + "\r\n");
                HtmlHelp.SaveStringToTxt(ex.Message + "\r\n" + ex.StackTrace + "\r\n\r\n", "Error.txt");
            }
            finally
            {
                //if (!IsSingle)
                //{
                //    Mut.RemoveGThread();
                //}
            }
        }
Ejemplo n.º 2
0
 protected void AddErrorMsg(string msg)
 {
     try
     {
         MyForm.BeginInvoke(new Action(() =>
         {
             MyForm.RtxtError.AppendText(msg);
         }));
     }
     catch { }
 }
Ejemplo n.º 3
0
 protected void AddSuccessMsg(string msg)
 {
     try
     {
         MyForm.BeginInvoke(new Action(() =>
         {
             MyForm.RtxtSuccess.AppendText(msg);
             ++count;
             if (count >= 500)
             {
                 count = 0;
                 MyForm.RtxtSuccess.Text = "";
             }
         }));
     }
     catch { }
 }