CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 1999
    Posts
    18

    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



  2. #2
    Join Date
    May 1999
    Posts
    318

    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 ...







  3. #3
    Join Date
    Aug 1999
    Posts
    18

    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


  4. #4
    Guest

    Re: Multitasking in Win 3.1

    do you have tried to process the WM_COMMNOTIFY message in DefWindowProc methode?


  5. #5
    Join Date
    Aug 1999
    Posts
    18

    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.



  6. #6
    Join Date
    Mar 2003
    Location
    Republic of Moldova
    Posts
    3

    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
  •  





Click Here to Expand Forum to Full Width

Featured