Пример #1
0
        public void TaskWorkWrongAgainStart()
        {
            //多线程处理
            DateTime t1    = DateTime.Now;
            int      pcNum = 1;

            //初始化队列
            while (true)
            {
                Thread.Sleep(1000);
                #region 工作信息输出
                OutPutWrite(listWrongList.Count);
                #endregion

                #region  处理工作队列
                while ((threadCounter.getThreadNum("tc") < MaxThreadNum) && listWrongList.Count > 0 && !isreturn)
                {
                    //没有 批次,不应该开启新的队列,而要等到所有队列处理结束
                    threadCounter.writerCounter("pcAdd");
                    threadCounter.writerCounter("tcAdd"); //放在线程外调整线程数。前防止主线程提前更新该计数器。
                    WorkWrongAgainArgs workWrongAgainArgs = new WorkWrongAgainArgs(threadCounter, listWrongList[0]);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(WorkWrongAgainAction), workWrongAgainArgs);
                    listWrongList.RemoveAt(0);
                }

                #endregion

                #region 所有任务处理完毕
                if ((threadCounter.getThreadNum("tc") == 0) && (listWrongList.Count <= 0) && pcNum > PageCount)//判断线程数和之前显示会有延迟
                {
                    Console.WriteLine("WorkWrongAgain任务处理完毕");
                    DateTime t2 = DateTime.Now;
                    Console.WriteLine(CommonHelper.DateDiff(t1, t2));
                    break;
                }
                #endregion
            }
        }
Пример #2
0
        public void WorkWrongAgainAction(object objArgs)
        {
            //工作处理单个月份
            WorkWrongAgainArgs workWrongAgainArgs = objArgs as WorkWrongAgainArgs;    //数包装器
            HttpWrongInfo      httpWrongInfo      = workWrongAgainArgs.HttpWrongInfo; //参数分解
            ThreadCounter      treadCounter       = workWrongAgainArgs.ThreadCounter; //参数分解

            try
            {
                AlbumWorkManager albumClawWorkManager = new AlbumWorkManager();
                albumClawWorkManager.GetOneAlbumAllSong(httpWrongInfo.AlbumUrl);
                sqlExecute.Update_XM_HttpWrongByWrongId(httpWrongInfo);

                threadCounter.writerCounter("fcAdd"); //完成 计数
                threadCounter.writerCounter("tcSub"); //释放线程数
            }
            catch (Exception ex)
            {
                threadCounter.writerCounter("tcSub"); //释放线程数
                threadCounter.writerCounter("ecAdd"); //错误  计数
                LogNet.LogBLL.Info("XM_AlbumClawWorkAction", ex);
                return;
            }
        }