PStat v1.32 A generalized framework
for executing a lengthy operation in a thread.
For developers who use MFC, this is a module which provides a single easy to
use function which allows one of your functions to be executed in a separate thread.
Feedback is provided by a progress dialog which can optionally be cancelled. The
sample application included with PStat allows you to calculate the 1,000,000th prime
number both with and without PStat. Try using the "without PStat" option
from the test program and tab to another program, when you tab back you will notice
that it's window is not redrawn because it is not responding to any window messages.
Now try the same with PStat, Notice the difference!
When executed with PStat, while your function is being executed a progress dialog
will be displayed as:
If you want to allow the user to cancel the operation during your function then
the progress dialog can be displayed with a cancel button as:
The function PStat provides allows a number of values to be modified, these include
the caption to use on the progress dialog and the priority to use when executing
the thread. The enclosed zip file contains source
for the routine and also includes a VC 2017 workspace file to build a small dialog
based app which calculates the 1,000,000th prime number both with and without PStat.
Copyright
- You are allowed to include the source code in any product (commercial, shareware,
freeware or otherwise) when your product is released in binary form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you are
only allowed to distribute versions released by the author. This is to maintain
a single distribution point for the source code.
Updates
v1.32 (5 May 2022)
- Updated copyright details.
- Updated the code to use C++ uniform initialization for all variable
declarations.
v1.31 (4 April 2020)
- Updated copyright details.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.30 (26 December 2019)
- Fixed various Clang-Tidy static code analysis warnings in the code.
v1.29 (23 September 2019)
- Replaced thread safe variables with std::atomic variables.
- Replaced BOOL throughout the codebase with bool
- Code now uses GetTickCount64 instead of SystemTimeToFileTime
v1.28 (22 September 2019)
- Fixed a number of compiler warnings when the code is compiled with VS
2019 Preview
v1.27 (3 June 2019)
- Updated copyright details.
- Updated the code to clean compile on VC 2019
v1.26 (29 October 2018)
- Updated copyright details.
- Fixed a number of C++ core guidelines compiler warnings. These changes
mean that the code will now only compile on VC 2017 or later.
v1.25 (21 January 2017)
- Updated copyright details.
- Updated the code to compile cleanly on VC 2010 - 2015.
- Removed the VC6 style classwizard comments from the code.
- Replaced NULL throughout the codebase with nullptr
- Moved all the configuration values used by the CProgressThreadDlg class
into a new CProgressThreadSettings class.
- Added SAL annotations to all the code
- Refactored all the setup code in CProgressThreadDlg::OnInitDialog into various
virtual methods.
- The progress control is now marked as paused when the confirm cancel messagebox
is displayed.
- Updated the sample app's application icon
v1.24 (23 July 2007)
- Updated copyright details.
- Optimized CProgressThreadDlg constructor code.
- CProgressThreadInfo is now no longer derived from CObject as it was not
really required.
- Code now uses newer C++ style casts instead of C style casts.
- Addition of a CPROGRESSTHREADDLG_EXT_CLASS preprocessor macro to make the
code easier to use in an extension dll.
- Restructured code to avoid need for internal CProgressThreadInfo class.
- Made the Cancel button's ID on the IDD_PSTAT_PROGRESS_WITH_CANCEL "IDCANCEL".
- Code now internally thread protects the "m_bCancelled" and "m_bOkToClose"
member variables.
- FUNCTION_WITH_PROGRESS function is now declared as PSTAT_FUNCTION and returns
a void. It is also now scoped in the CProgressThreadDlg class.
- Updated sample app to clean compile on VC2005.
- Updated the documentation to use the same style as the web site.
v1.23 (3 February 2003)
- Re-implemented a busy loop using a CEvent in ProgressDialogWorkerThread.
- Implemented synchronous closure of the worker thread.
- Updated copyright details.
v1.22 (31 March 2000)
- Fixed a race condition which existing in the worker thread. The issue was
that the dialog could be closed before the CSingleLock destructor was called
in the worker thread which resulted in an access violation.
v1.21 (28 March 2000)
- Changed dialog resources which pstat uses to use the prefix ID._PSTAT_...
- Update documentation about its usage.
v1.2 (8 November 1998)
- Added an option to confirm cancel by means of a message box.
- General tidy up of the code.
- Inclusion of VC 5 workspace files now as standard.
- All code now compiles cleanly at warning level 4.
- Code now supports UNICODE and build configurations are now provided.
- HTML help file now provided.
v1.1 (18 February 1998)
- Fixed a bug where the worker thread was trying to close a dialog before
it was created. A CEvent member of CProgressThreadDlg now protects this. Also
removed the usual AppWizard comments from the demo program.
v1.0 (27 March 1997)