Index: src/ch/task.cpp =================================================================== diff -u -N -r5057e08b0cc064972abeb94a488e5f12d9db14a0 -r9352ed0c4fe447a36bc728640c307be6d41455fd --- src/ch/task.cpp (.../task.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) +++ src/ch/task.cpp (.../task.cpp) (revision 9352ed0c4fe447a36bc728640c307be6d41455fd) @@ -147,9 +147,9 @@ int iOffset; int iCount=0; m_cs.Lock(); - for (int i=0;iGetPath(); strText.MakeLower(); iOffset=strText.Find(strOld, 0); @@ -408,9 +408,9 @@ else m_nProcessed+=m_ucCurrentCopy*m_nAll; - for (int i=0;iSetKillFlag(); // send an info about finishing + for(size_t stIndex = 0; stIndex < GetSize(); ++stIndex) + { + GetAt(stIndex)->SetKillFlag(); // send an info about finishing + } // wait for finishing and get rid of it - for (int i=0;iGetKilledFlag()) + while(!pTask->GetKilledFlag()) Sleep(10); pTask->CleanupAfterKill(); @@ -1309,9 +1311,9 @@ void CTaskArray::RemoveFinished(CTask** pSelTask) { m_cs.Lock(); - for (int i=0;iGetStatus(ST_STEP_MASK) == ST_FINISHED || pTask->GetStatus(ST_STEP_MASK) == ST_CANCELLED)) { @@ -1327,7 +1329,7 @@ // delete data delete pTask; - static_cast*>(this)->RemoveAt(i); + static_cast*>(this)->RemoveAt(stIndex); m_cs.Unlock(); return; @@ -1396,34 +1398,36 @@ void CTaskArray::TasksBeginProcessing() { - for (int i=0;iBeginProcessing(); + for(size_t stIndex = 0; stIndex < GetSize(); ++stIndex) + { + GetAt(stIndex)->BeginProcessing(); + } } void CTaskArray::TasksPauseProcessing() { - for (int i=0;iPauseProcessing(); + for(size_t stIndex = 0; stIndex < GetSize(); ++stIndex) + GetAt(stIndex)->PauseProcessing(); } void CTaskArray::TasksResumeProcessing() { - for (int i=0;iResumeProcessing(); + for(size_t stIndex = 0; stIndex < GetSize(); ++stIndex) + GetAt(stIndex)->ResumeProcessing(); } void CTaskArray::TasksRestartProcessing() { - for (int i=0;iRestartProcessing(); + for(size_t stIndex = 0; stIndex < GetSize(); ++stIndex) + GetAt(stIndex)->RestartProcessing(); } bool CTaskArray::TasksRetryProcessing(bool bOnlyErrors/*=false*/, UINT uiInterval) { bool bChanged=false; - for (int i=0;iRetryProcessing(bOnlyErrors, uiInterval)) + if (GetAt(stIndex)->RetryProcessing(bOnlyErrors, uiInterval)) bChanged=true; } @@ -1432,8 +1436,8 @@ void CTaskArray::TasksCancelProcessing() { - for (int i=0;iCancelProcessing(); + for(size_t stIndex = 0; stIndex < GetSize(); ++stIndex) + GetAt(stIndex)->CancelProcessing(); } ull_t CTaskArray::GetPosition() @@ -1488,9 +1492,9 @@ bFlag=false; else { - for (int i=0;iGetStatus(); + uiStatus=GetAt(stIndex)->GetStatus(); bFlag=((uiStatus & ST_STEP_MASK) == ST_FINISHED || (uiStatus & ST_STEP_MASK) == ST_CANCELLED || (uiStatus & ST_WORKING_MASK) == ST_PAUSED || ((uiStatus & ST_WORKING_MASK) == ST_ERROR && !GetConfig().get_bool(PP_CMAUTORETRYONERROR))); @@ -2508,10 +2512,21 @@ } } +int CTask::OnBeginTask() +{ + return rand(); +} + +int CTask::OnEndTask(int i) +{ + return i + 2; +} + UINT CTask::ThrdProc(LPVOID pParam) { TRACE("\n\nENTERING ThrdProc (new task started)...\n"); CTask* pTask=static_cast(pParam); + pTask->OnBeginTask(); chcore::IFeedbackHandler* piFeedbackHandler = pTask->GetFeedbackHandler(); tstring_t strPath = pTask->GetTaskPath(); @@ -2719,6 +2734,8 @@ return 0xffffffff; // almost like -1 } + pTask->OnEndTask(7); + TRACE("TASK FINISHED - exiting ThrdProc.\n"); return 0; }