I want to install a worker thread to verify some parameters, which can
be configurated by a dialog as well as by the integrated webserver.
All required parameters I need to verify the user inputs are in one
In which class is it recommended to start the worker thread? I want to
use one place to start this worker thread which is reachable for both
situations: the user made some inputs by the webserver or by the
dialog. Therefore I choose the MyParamClass to start this worker
thread. But having the option to shutdown the worker thread if the
application should be closed, I need a cview / dialog class which
terminates this thread in such cases. Is it a good way to install
another cview class for this worker thread ?
myparams = new MyThreadParams(NULL, shutdown-event, threadview,
mythread = AfxBeginnThread(WorkerThreadProc, (LPVOID) myparams,
THREAD_PRIORITY_NORMAL, 0, 0, NULL);
//close also worker thread if available
Another question: I also want to acchieve that the worker thread could
be called only once. Therefore I need some synchronisation. Because if
one user starts the worker thread by the dialog and another user tries
to start the worker thread by the webserver a few seconds later; I
could get into some troubles. In both cases, the worker thread is
always started from the main thread. I don`t want to block the main
thread either, if the worker thread is already running. Which way or
solution is here recommended?