CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Dialog Box Busy

  1. #1
    Join Date
    Mar 2014
    Posts
    2

    Dialog Box Busy

    Hi,

    My dialog application uploads a file to a microprocessor system through an RS-232 port.
    Clicking a button starts uploading.
    While running the application doesn't accept any button clicks.
    A progress bar is following the upload procedure.

    The problem is that very often the progress bar freezes and a sand clock shows up. The process always goes to the end and eventually the progress bar gets completed but but meanwhile everything stays frozen.
    The same happens if the user tries to move the dialog while running or change the focus out of the dialog.

    Does anybody know how to fix similar issues?

    Thanks,
    Ivan

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Dialog Box Busy

    Just move the code working with the serial port into a worker thread. Use PostMessage to inform the main GUI thread about the progress bar position.
    Have a look at the Using Worker Threads
    Victor Nijegorodov

  3. #3
    Join Date
    Mar 2014
    Posts
    2

    Re: Dialog Box Busy

    Quote Originally Posted by VictorN View Post
    Just move the code working with the serial port into a worker thread. Use PostMessage to inform the main GUI thread about the progress bar position.
    Have a look at the Using Worker Threads
    Thank you, Victor,

    I'll investigate this document in details in order to understand how to create a Worker Thread.
    I found a temporary solution in the document: added the line "PeekMessage(&msg, NULL, 0, 0);" inside the upload processing loop and the Progress Bar is no longer freezing.

    Ivan

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Dialog Box Busy

    Quote Originally Posted by IvanCh View Post
    Thank you, Victor,

    I'll investigate this document in details in order to understand how to create a Worker Thread.
    I found a temporary solution in the document: added the line "PeekMessage(&msg, NULL, 0, 0);" inside the upload processing loop and the Progress Bar is no longer freezing.

    Ivan
    That's the simple way of solving it, kind of. I say, kind of, because you risk the chance of losing serial port data when you read the seral port in the main ui thread. This is because the user can interrupt the reading by doing something simple such as moving the mouse or dragging the dialog around. It's better to have a dedicated worker thread read the serial port as Victor suggested - then any UI operations the user performs won't get in the way of reading from the serial port.

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