Ejemplo n.º 1
0
 void addWorkTask(ThreadWorkModel md, int idx, ImageModel imgMd)
 {
     lock (md.lockCom) {
         //md.queImg.Enqueue(img);
         md.mapData[idx] = imgMd;
     }
 }
Ejemplo n.º 2
0
        void workProc(object data)
        {
            ThreadWorkModel    md        = data as ThreadWorkModel;
            ThreadCollectModel thCollect = mdThreadCollect;

            do
            {
                if (md.needStop)
                {
                    return;
                }

                const int waitTime = 10;

                Dictionary <int, ImageModel> mapData = new Dictionary <int, ImageModel>();
                lock (md.lockCom) {
                    foreach (int key in md.mapData.Keys)
                    {
                        mapData[key] = md.mapData[key];
                    }

                    md.mapData = new Dictionary <int, ImageModel>();
                }

                if (mapData.Count <= 0)
                {
                    Thread.Sleep(waitTime);
                    continue;
                }

                foreach (int key in mapData.Keys)
                {
                    PNG png = formatPng(mapData[key]);

                    lock (thCollect.lockCom) {
                        thCollect.mapData[key] = png;
                    }
                }
            } while(!md.needStop);
        }
Ejemplo n.º 3
0
        //Thread thManage = null;
        //Thread thCollect = null;
        //bool isThreadStop = false;
        void initThread(string savePath, int startFrameIdx, int frameCount, int fps)
        {
            clearThread();

            nowProgress   = 0;
            totalProgress = frameCount + 1;

            mdThreadManage = new ThreadManageModel();
            mdThreadManage.startFrameIdx  = startFrameIdx;
            mdThreadManage.frameCount     = frameCount;
            mdThreadManage.fps            = fps;
            mdThreadManage.isTransparency = true;
            mdThreadManage.th             = new Thread(manageProc);
            mdThreadManage.th.Priority    = ThreadPriority.BelowNormal;
            mdThreadManage.th.Start(mdThreadManage);

            mdThreadCollect             = new ThreadCollectModel();
            mdThreadCollect.th          = new Thread(collectProc);
            mdThreadCollect.frameCount  = frameCount;
            mdThreadCollect.fps         = fps;
            mdThreadCollect.savePath    = savePath;
            mdThreadCollect.th.Priority = ThreadPriority.BelowNormal;
            mdThreadCollect.th.Start(mdThreadCollect);

            int count = Environment.ProcessorCount - 1;

            count = Math.Max(1, count);
            for (int i = 0; i < count; ++i)
            {
                ThreadWorkModel md = new ThreadWorkModel();
                md.idx         = i;
                md.th          = new Thread(workProc);
                md.th.Priority = ThreadPriority.BelowNormal;
                lstThreadWork.Add(md);
                md.th.Start(md);
            }
        }
Ejemplo n.º 4
0
 void removeFirstWorkTask(ThreadWorkModel md, int idx)
 {
     lock (md.lockCom) {
         md.mapData.Remove(idx);
     }
 }