Supposedly this magic number -17891602 (0xFEEEFEEE) is what you observed in
record->recording after this object was deleted. Here is a little secret.
any period of time. If you freed some memory, you're not supposed to touch
it ever. There is no reliable way to check if an object is alive or freed.
DO NOT EVER USE SuspendThread! This is just wrong! How do you know
where the thread is
when you suspend it? Rethink the design. For example, if it happens
to be in the
storage allocator when you call SuspendThread, no other thread in your
process will be
able to do storage allocation; they will all hang.
How do you think the record thread is going to handle that
WM_RECORDSOUND_STOPRECORDING
message if it is suspended?
We would need to know what the record thread is doing and how it is doing
it before we
could tell you the correct way to handle this, but SuspendThread is a
guaranteed way to
catastrophic failure.
----------------------------
Start:
record->PostThreadMessage(WM_RECORDSOUND_STOPRECORDING,0,0);
play1->PostThreadMessage(WM_PLAYSOUND_STARTPLAYING,0,0);
Stop:
record->PostThreadMessage(WM_RECORDSOUND_STOPRECORDING,0,0);
play1->PostThreadMessage(WM_PLAYSOUND_STOPPLAYING,0,0);
Exit (delete):
if(record->recording==TRUE)
{
record->PostThreadMessage(WM_RECORDSOUND_STOPRECORDING,0,0);
record->PostThreadMessage(WM_RECORDSOUND_ENDTHREAD,0,0);
}
if(record->recording!= -17891602)
{
::PostQuitMessage(0);
delete record;
}
if(play1->Playing==TRUE)
{
play1->PostThreadMessage(WM_PLAYSOUND_STOPPLAYING,0,0);
play1->PostThreadMessage(WM_PLAYSOUND_ENDTHREAD,0,0);
}
if(play1->Playing!=-17891602)
{
play1->ExitInstance();
delete play1;
}
Regards,
Rehmet