If the original program is working well, then that is good. You could leave good enough alone, but I still think that you should change your thread logic to be more object oriented as I have mentioned. As it stands, it is hard to pick up how things work from looking at your code: you have UI mixed with lower level functionality. A thread class modularizes everything so much better and makes for easier reading, hence debugging if something should need looking at at a later date.
But hey, it is your project... :)
>> do you have any idea why, when it is terminated by clicking the 'x' button, the debugger indicates memory leaks?
I see the following after I start the debugger, press the start button, then close the app:
<code>
Detected memory leaks!
Dumping objects ->
{542} normal block at 0x00DB16A0, 16 bytes long.
Data: < > A8 15 DB 00 CD CD CD CD CD CD CD CD CD CD CD CD
{541} normal block at 0x0003FBE8, 32 bytes long.
Data: < > A0 16 DB 00 00 00 00 00 00 00 00 00 00 00 00 00
{526} normal block at 0x00DB3FA0, 28 bytes long.
Data: < > 00 00 00 00 CD CD CD CD CD CD CD CD E8 FB 03 00
Object dump complete.
</code>
So I add the following to CWinThreadTestApp::InitInstance():
<code>
_CrtSetBreakAlloc ( 542 );
_CrtSetBreakAlloc ( 541 );
_CrtSetBreakAlloc ( 526 );
</code>
Now when the debugger is started, I immediately get a debug break on the line:
<code>
OpRequestQ = (queue<OpRequestObj*>*)
new queue<OpRequestObj*>; //[MAX_CONCURRENT_POLLS+1];
</code>
so, add
<code>
if ( OpRequestQ ) delete OpRequestQ;
</code>
to your destructor :) _CrtSetBreakAlloc really is a great function to make extensive use of when necessary :)