I have a program that uses the serial port with Windows XP (it is written in Visual C++ 4 - yes, 4!). It has a separate thread for receiving data from the port.
The problem is that, while everything works fine in both Debug and Release versions, there is a problem with exiting the application. When I exit from the Release version, and try to restart it, I get a message saying that the port cannot be opened. Task Manager says the application still has a process running. This doesn't happen with the Debug version. I am using CloseHandle, which succeeds, and I am setting the port handle to NULL afterwards.
This is the first time I'm writing a multiple-thread application for Windows, so I'm a bit lost. Why don't ALL my threads exit when I exit my program under Release configuration?
Does anybody know what I can do to make the program work under Release the same way it does under Debug? I'd really appreciate the help. Thanks!