File Download Tracking
Posted on 2003-10-24
I have a possible solution for a problem and I wanted to bounce it off the experts. I need to keep track of the file downloads that my program starts. Here is the way that it manages them. The document is told that there is a download to do, and it forms a DCCConnection object which basically uses a CSocket object inside of a worker thread to handle the download. The worker thread creates the socket, connects, and loops to recieve bytes until it is complete or it gets cut off. I would like the document to be able keep track of all the downloads and report the status as well. Right now (I don't even know why it works but it does) it creates the DCCConnection in a function starts the thread, and then the reference goes out of scope, however, the download continues successfully. So there is this unreferenced worker thread out there doing its own thing.
Here is my planned idea. I think that it may be a good idea to keep a CTYpedPtrList of thread pointers (representing the worker threads) and have the thread send a message to the main thread with a COMPLETE or FAIL parameter and a thread ID to remove from the list. The thing is...I need the document to get the message. I would appreciate any ideas on how to best achieve such a structure. THank you all for your help.