Microsoft developers are fallible
Snicker, snicker. No really, we are. <innocent look>
I discovered a bug in the Animate3 which I did for Power to the Developers part 2. I was closing the message queue with CloseHandle when I was supposed to use CloseMsgQueue. Bad Mike. Of course, I also cleverly forgot to link the animate sample in that entry, so maybe you haven't downloaded it yet. I've updated the sample (it's here by the way) and added the link to Power to the Developers. If you downloaded the sample yesterday, please download it again and throw the old version out.
Sorry for the Confusion.
Mike Calligaro
Comments
- Anonymous
September 12, 2005
Shouldn't you also have to do a CloseHandle on the PowerNotificationThread thread handle. Otherwise the OS does not free all the system resources with the thread even if it exits. - Anonymous
September 19, 2005
Ed, I'm going to waffle a bit. You're right that I should have closed the handle. This is a sample and it's setting a bad example.
However, in THIS case, the close handle isn't necessary. The thread runs until just before the app exits. Thread handles are cleaned up on process exit.
Still, this is a good catch. The next time I'm in that code, I'll clean it up and close the handle. Thanks!
Mike - Anonymous
September 19, 2005
Okay, I uploaded a new version (same location) that closes the thread handle right after the call to CreateThread. It bugged me that my sample was misleading. Thanks for catching the problem, Ed.
(Sorry it took me so long to get back with you. I missed a number of comments and have been going through and finding old ones I hadn't seen yet.)
Mike