Beispiel #1
0
        private static void ParseURLThread(object o)
        {
            DateTime         lastParseTime = new DateTime();
            ProductCollector collector     = o as ProductCollector;

            while (!collector._stopThread)
            {
                DateTime now   = DateTime.Now;
                TimeSpan delta = now - lastParseTime;
                if (delta.TotalSeconds > 70)
                {
                    // 开始解析
                    Debugger.Log(0, null, "开始解析");

                    collector.ParseTkURLList();
                    lastParseTime = now;
                }
                Thread.Sleep(1000);
            }
        }
Beispiel #2
0
        private static void MonitorThreadProc(object o)
        {
            DateTime         lastCollectTime = new DateTime();
            ProductCollector colllector      = o as ProductCollector;

            while (!colllector._stopThread)
            {
                DateTime nowTime = DateTime.Now;
                TimeSpan delta   = nowTime - lastCollectTime;
                if (delta.TotalSeconds > colllector._interval * 60 && nowTime.Hour >= colllector._startTime && nowTime.Hour < colllector._endTime)
                {
                    Debugger.Log(0, null, "开始采集");
                    // 先遍历QQ窗口列表
                    foreach (int item in colllector._monitorQQWndList)
                    {
                        QqWindowHelper a          = new QqWindowHelper((IntPtr)item);
                        string         strContent = a.GetContent();
                        colllector.ParseChatContent(a.GetContent());
                        if (colllector._stopThread)
                        {
                            break;
                        }
                    }

                    // 再重试之前失败的
                    colllector.RetryFailedURLList();

                    lastCollectTime = nowTime;
                }

                if (colllector._stopThread)
                {
                    break;
                }
                Thread.Sleep(1000);
            }
        }