|
-
December 29th, 2006, 05:11 AM
#3
Re: Avoiding memory leaks when multithreading?
Yes, you can post a message to the main window from your threads, just before the last line (which has to be a simple return 0, no ExitThread needed).
From you main window procedure, get the message and call CloseHandle. Finally, get WM_DESTROY and call WaitForMultipleObjects on the thread handles that haven't expired yet (and/or send them a message to notify about program termination).
If you don't want to worry about thread termination, just close their handle as soon as you create them (as Krishnaa has already suggested).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|