diff --git a/HashSave.cpp b/HashSave.cpp index 608fadb..072458d 100644 --- a/HashSave.cpp +++ b/HashSave.cpp @@ -186,6 +186,8 @@ VOID __fastcall HashSaveWorkerMain( PHASHSAVECONTEXT phsctx ) dwStarted = GetTickCount(); #endif + class CanceledException {}; + // concurrency::parallel_for_each(vecpItems.cbegin(), vecpItems.cend(), ... auto per_file_worker = [&](PHASHSAVEITEM pItem) { @@ -201,7 +203,7 @@ VOID __fastcall HashSaveWorkerMain( PHASHSAVECONTEXT phsctx ) // Allocate a read buffer (one buffer is cached per worker thread by Alloc/Free) pbBuffer = (PBYTE)concurrency::Alloc(READ_BUFFER_SIZE); if (pbBuffer == NULL) - return; + throw CanceledException(); } #endif @@ -229,7 +231,7 @@ VOID __fastcall HashSaveWorkerMain( PHASHSAVECONTEXT phsctx ) if (phsctx->status == PAUSED) WaitForSingleObject(phsctx->hUnpauseEvent, INFINITE); if (phsctx->status == CANCEL_REQUESTED) - return; + throw CanceledException(); // Write the data HashCalcWriteResult(phsctx, pItem); @@ -240,12 +242,16 @@ VOID __fastcall HashSaveWorkerMain( PHASHSAVECONTEXT phsctx ) }; #pragma warning(pop) + try + { #ifdef USE_PPL - if (bMultithreaded) - concurrency::parallel_for_each(vecpItems.cbegin(), vecpItems.cend(), per_file_worker); - else + if (bMultithreaded) + concurrency::parallel_for_each(vecpItems.cbegin(), vecpItems.cend(), per_file_worker); + else #endif - std::for_each(vecpItems.cbegin(), vecpItems.cend(), per_file_worker); + std::for_each(vecpItems.cbegin(), vecpItems.cend(), per_file_worker); + } + catch (CanceledException) {} // ignore cancellation requests #ifdef _TIMED if (phsctx->cTotal > 1 && phsctx->status != CANCEL_REQUESTED) diff --git a/HashVerify.cpp b/HashVerify.cpp index 56ef2fa..88dc3e7 100644 --- a/HashVerify.cpp +++ b/HashVerify.cpp @@ -533,6 +533,8 @@ VOID __fastcall HashVerifyWorkerMain( PHASHVERIFYCONTEXT phvctx ) // sound notification of completion when appropriate phvctx->dwStarted = GetTickCount(); + class CanceledException {}; + // concurrency::parallel_for_each(phvctx->index, phvctx->index + phvctx->cTotal, ... auto per_file_worker = [&](PHASHVERIFYITEM pItem) { @@ -543,7 +545,7 @@ VOID __fastcall HashVerifyWorkerMain( PHASHVERIFYCONTEXT phvctx ) // Allocate a read buffer (one buffer is cached per worker thread by Alloc/Free) pbBuffer = (PBYTE)concurrency::Alloc(READ_BUFFER_SIZE); if (pbBuffer == NULL) - return; + throw CanceledException(); } else #endif @@ -594,7 +596,7 @@ VOID __fastcall HashVerifyWorkerMain( PHASHVERIFYCONTEXT phvctx ) if (phvctx->status == PAUSED) WaitForSingleObject(phvctx->hUnpauseEvent, INFINITE); if (phvctx->status == CANCEL_REQUESTED) - return; + throw CanceledException(); // Part 3: Do something with the results if (whres.dwFlags) @@ -643,18 +645,21 @@ VOID __fastcall HashVerifyWorkerMain( PHASHVERIFYCONTEXT phvctx ) PostMessage(phvctx->hWnd, HM_WORKERTHREAD_UPDATE, (WPARAM)phvctx, (LPARAM)pItem); }; + try + { #ifdef USE_PPL + if (bMultithreaded) + concurrency::parallel_for_each(phvctx->index, phvctx->index + phvctx->cTotal, per_file_worker); + else +#endif + std::for_each(phvctx->index, phvctx->index + phvctx->cTotal, per_file_worker); + } + catch (CanceledException) {} // ignore cancellation requests + if (bMultithreaded) - { - concurrency::parallel_for_each(phvctx->index, phvctx->index + phvctx->cTotal, per_file_worker); DeleteCriticalSection(&updateCritSec); - } else -#endif - { - std::for_each(phvctx->index, phvctx->index + phvctx->cTotal, per_file_worker); VirtualFree(pbTheBuffer, 0, MEM_RELEASE); - } // Play a sound to signal the normal, successful termination of operations, // but exempt operations that were nearly instantaneous diff --git a/installer/HashCheck.nsi b/installer/HashCheck.nsi index 22357ec..a235da4 100644 --- a/installer/HashCheck.nsi +++ b/installer/HashCheck.nsi @@ -6,7 +6,7 @@ Unicode true Name "HashCheck" -OutFile "HashCheckSetup-v2.4.0.37-beta.exe" +OutFile "HashCheckSetup-v2.4.0.38-beta.exe" RequestExecutionLevel admin ManifestSupportedOS all @@ -53,15 +53,15 @@ FunctionEnd !insertmacro MUI_LANGUAGE "Ukrainian" !insertmacro MUI_LANGUAGE "Catalan" -VIProductVersion "2.4.0.37-beta" +VIProductVersion "2.4.0.38-beta" VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "HashCheck Shell Extension" -VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "2.4.0.37-beta" +VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "2.4.0.38-beta" VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "Installer distributed from https://github.com/gurnec/HashCheck/releases" VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "" VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "" VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright © Kai Liu, Christopher Gurnee, Tim Schlueter, et al. All rights reserved." VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Installer (x86/x64) from https://github.com/gurnec/HashCheck/releases" -VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "2.4.0.37-beta" +VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "2.4.0.38-beta" ; With solid compression, files that are required before the ; actual installation should be stored first in the data block, diff --git a/version.h b/version.h index a804098..f975821 100644 --- a/version.h +++ b/version.h @@ -12,10 +12,10 @@ #define HASHCHECK_NAME_STR "HashCheck Shell Extension" // Full version: MUST be in the form of major,minor,revision,build -#define HASHCHECK_VERSION_FULL 2,4,0,37 +#define HASHCHECK_VERSION_FULL 2,4,0,38 // String version: May be any suitable string -#define HASHCHECK_VERSION_STR "2.4.0.37-beta" +#define HASHCHECK_VERSION_STR "2.4.0.38-beta" #ifdef _USRDLL // PE version: MUST be in the form of major.minor