Example #1
0
        void manageProc(object data)
        {
            ThreadManageModel md = data as ThreadManageModel;
            //if(mdThreadManage == null) {
            //	return;
            //}

            Window win = MainModel.ins.mainWin;

            for (int i = 0; i < md.frameCount; ++i)
            {
                ImageModel imgMd = null;
                win.Dispatcher.Invoke(() => {
                    imgMd = getImageModelByFrame(md.startFrameIdx + i, md.isTransparency);
                });

                if (md.needStop)
                {
                    return;
                }

                if (imgMd == null)
                {
                    clearThread();
                    return;
                }

                int idx = findFreeThreadIdx();
                addWorkTask(lstThreadWork[idx], i, imgMd);
            }
        }
Example #2
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);
            }
        }