I recently discovered ATL's CThreadPool class and was very happy with this find. It's a neat little class that will take care of the syncronization semantics of having multiple worker threads to process some queue of taks to do. The tasks are fed to the CThreadPool object, by some extrnal process.
Now suppose one of the worker threads encounters an error, or has an exception. I don't mean the type of exceptions where you would want your whole application to just die, but it is something you want to do deal with more gracefully. By gracefully I mean the applicattion can die, but I need to do some clean up work and to put a propper message somewhere as to why it did.
What is the best way to transfer the error info (message, error code, source etc.) to the main thread owning the CThreadPool object?