コード例 #1
0
        public static BaseTaker factory(string name)
        {
            BaseTaker taker = null;

            if (string.Equals(name, "weibo"))
            {
                taker = new WeiboTaker();
            }
            else if (string.Equals(name, "twitter"))
            {
                taker = new TwitterTaker();
            }
            else if (string.Equals(name, "twitter2"))
            {
                taker = new TwitterTaker2();
            }
            else if (string.Equals(name, "twitter3"))
            {
                taker = new TwitterTaker3();
            }
            else
            {
                taker = new TwitterTaker2();
            }
            return(taker);
        }
コード例 #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            BaseTaker taker = BaseTaker.factory(takerKind);

            taker.setCookie(cookie);
            taker.setProxy(proxy);
            taker.setUid(uid);
            taker.setInterval(interval);
            taker.setTopCount(topCount);
            server.StartOnce(taker);
        }
コード例 #3
0
        public void start()
        {
            BaseTaker taker = BaseTaker.factory(takerKind);

            taker.setCookie(cookie);
            taker.setUid(uid);
            taker.setInterval(interval);
            taker.setTopCount(topCount);
            taker.setProxy(proxy);
            server.Start(taker);
            Win32Api.SystemUnsleepLock();
        }
コード例 #4
0
ファイル: Server.cs プロジェクト: xiaohhhh/QQSenderRobot
        /// <summary>
        /// 开始轮询抓取工作
        /// </summary>
        /// <param name="taker"></param>
        public void Start(BaseTaker taker)
        {
            flag       = 1;
            this.taker = taker;
            countdown  = taker.Interval;
            if (thread != null)
            {
                try
                {
                    thread.Abort();
                }catch (Exception)
                {
                }
                thread = null;
            }

            thread = new Thread(new ThreadStart(run));
            thread.Start();
        }
コード例 #5
0
ファイル: Server.cs プロジェクト: xiaohhhh/QQSenderRobot
 /// <summary>
 /// 异步执行一次抓取任务
 /// </summary>
 /// <param name="taker"></param>
 public void StartOnce(BaseTaker taker)
 {
     if (this.taker == null)
     {
         this.taker = taker;
     }
     if (onceWork == null)
     {
         onceWork = new BackgroundWorker();
         onceWork.WorkerReportsProgress      = false; // 设置可以通告进度
         onceWork.WorkerSupportsCancellation = true;  // 设置可以取消
         onceWork.DoWork += new DoWorkEventHandler(new DoWorkEventHandler(doWorkFunc));
     }
     //new Thread(new ThreadStart(runOnce)).Start() ;
     //onceWork.CancelAsync();
     if (!onceWork.IsBusy)
     {
         onceWork.RunWorkerAsync();
     }
 }