private void ProcessZipsStartThreads() { lock (_fileList) { _threadsBusyCount = _threadCount; for (int i = 0; i < _threadCount; i++) { if (procStatus.Count <= i) { procStatus.Add(false); } if (procStatus[i]) { continue; } CProcessZip cpz = new CProcessZip { ThreadId = i, GetNextFileCallBack = GetNextFileCallback, SetFileStatusCallBack = SetFileStatusCallback, StatusCallBack = StatusCallBack }; procStatus[i] = true; Thread t = new Thread(cpz.MigrateZip); t.Start(); } } }
private void ProcessZipsStartThreads() { _fileIndex.Value = 0; _threadsBusyCount = _threadCount; for (int i = 0; i < _threadCount; i++) { CProcessZip cpz = new CProcessZip { ThreadId = i, GetNextFileCallBack = GetNextFileCallback, SetFileStatusCallBack = SetFileStatusCallback, StatusCallBack = StatusCallBack }; Thread t = new Thread(cpz.MigrateZip); t.Start(); } }
private void SetUpWorkerThreads() { _threadCount = tbProccessors.Value; bccFile?.CompleteAdding(); foreach (ThreadProcess tp in _threads) { StatusPanel.Controls.Remove(tp.threadLabel); tp.threadLabel.Dispose(); StatusPanel.Controls.Remove(tp.threadProgress); tp.threadProgress.Dispose(); tp.cProcessZip.ProcessFileStartCallBack = null; tp.cProcessZip.StatusCallBack = null; tp.cProcessZip.ProcessFileEndCallBack = null; tp.thread.Join(); } bccFile?.Dispose(); _threads.Clear(); bccFile = new BlockingCollection <cFile>(); for (int i = 0; i < _threadCount; i++) { ThreadProcess threadProcess = new ThreadProcess(); _threads.Add(threadProcess); Label pLabel = new Label { Visible = true, Left = 12, Top = 235 + 30 * i, Width = 225, Height = 15, Text = $"Processor {i + 1}" }; StatusPanel.Controls.Add(pLabel); threadProcess.threadLabel = pLabel; ProgressBar pProgress = new ProgressBar { Visible = true, Left = 12, Top = 250 + 30 * i, Width = 225, Height = 12 }; StatusPanel.Controls.Add(pProgress); threadProcess.threadProgress = pProgress; CProcessZip cpzn = new CProcessZip { ThreadId = i, bcCfile = bccFile, ProcessFileStartCallBack = ProcessFileStartCallback, StatusCallBack = StatusCallBack, ProcessFileEndCallBack = ProcessFileEndCallback, pauseCancel = pc }; Thread t = new Thread(cpzn.MigrateZip); t.Start(); threadProcess.thread = t; threadProcess.cProcessZip = cpzn; } if (Height < 325 + 30 * _threadCount) { Height = 325 + 30 * _threadCount; } }