|
-
October 12th, 1999, 12:55 AM
#1
Multitasking in Win 3.1
Hi
I am writing an app for Windows 3.1 using VC++ 1.5 and I have a class which continuously polls the serial port (this class does not derive from any MFC class). While polling the serial port I want the GUI of my application to function normally. How can I make Windows service my gui while the polling goes on in the background???
Thanks for any help offered.
Zubin
-
October 12th, 1999, 01:23 AM
#2
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 ...
-
October 13th, 1999, 01:58 AM
#3
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
-
October 13th, 1999, 03:58 AM
#4
Re: Multitasking in Win 3.1
do you have tried to process the WM_COMMNOTIFY message in DefWindowProc methode?
-
October 13th, 1999, 06:45 PM
#5
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.
-
March 16th, 2003, 04:43 AM
#6
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|