Re: Multitasking in Win 3.1
Win 3.1 is a cooperative system that means it is not a real multitasking system.
To avoid having the user interface blocks do the following :
while ( PeekMessage(&msg,NULL,0,0,PM_REMOVE) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
But be careful because the GUI of your application cannot works (events, ...) because you code pointer is doing something else.
The better way is to handle your serial port communication asynchrounsly.
For example send your message on serail port once and using a timer poll the serial port. By this way your application will not be blocked.
I think it is the only way to take ...
Re: Multitasking in Win 3.1
I was looking for a better way but like you I think a timer in the application message loop is the only solution for Windows 3.1
Thanks
Zubin
Re: Multitasking in Win 3.1
do you have tried to process the WM_COMMNOTIFY message in DefWindowProc methode?
Re: Multitasking in Win 3.1
WM_COMMNOTIFY is buggy as hell on Win 3.1 and eventually stops working. There is a bug report about it on the libraries disk in the Visual C++ 6 package.
try to put into separated thread
In this case it is better to put serial pooling code into separated thread, and make some kind of callback functions that will be called by this thread when new data will be received.
Or, as was told before, perform an ansynchronous communication oriented on different events, overlapped structures etc.