Problem with Work Threads and MFC MDI App, debug vs release
Posted on 2003-10-29
I have an MDI App, which was generated using the Visual Studio V6.0 Wizard.
I create a doc/view template and in the doc I create a 'simple' worker thread. When this thread has done some processing, it does a PostMessage to the main UI thread/view.
I use CCriticalSection around a buffer which is shared between the 2 threads.
Under both debug and release mode this works fine and the view does some UI updating from the work thread. However in release mode, if the main app gets any other windows message, eg app losses focus. It crashes. Under debug this is fine.
If I remove the PostMessage call then no crash. If I remove the code inside the handler to the PostMessage, then still crash, dispite the handler getting the message.
Does anyone have any suggestions as to what maybe wrong?