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

Thread: refresh dialog

  1. #1
    Join Date
    Aug 2019
    Posts
    72

    refresh dialog

    Have a function as part of a dialog class which has some loops and so on and works. But during its run, the dialog needs its controls , etc. refreshed and update. For reasons can not use worker thread for this function. What's the best way to refresh/update dialog at the same time that the serial processes in this function are running. Without flickering.

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

    Re: refresh dialog

    Quote Originally Posted by @EE@ View Post
    Have a function as part of a dialog class which has some loops and so on and works. But during its run, the dialog needs its controls , etc. refreshed and update. For reasons can not use worker thread for this function. What's the best way to refresh/update dialog at the same time that the serial processes in this function are running. Without flickering.
    1. And what are the reasons you "can not use worker thread for this function"?
    2. The best way to use serial communication is to place the serial functions code in the secondary thread.
    Victor Nijegorodov

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: refresh dialog

    If it's an MFC dialog, UpdateData should do it

  4. #4
    Join Date
    Aug 2019
    Posts
    72

    Re: refresh dialog

    Victor:

    1. And what are the reasons you "can not use worker thread for this function"?

    need something more deterministic. The thread operation does not quite sync with operation in the library it calls. need to give more control to the library function.

    2. The best way to use serial communication is to place the serial functions code in the secondary thread.

    yes.
    Last edited by @EE@; March 15th, 2022 at 01:29 AM.

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

    Re: refresh dialog

    Quote Originally Posted by @EE@ View Post
    Victor:

    1. And what are the reasons you "can not use worker thread for this function"?

    need something more deterministic. The thread operation does not quite sync with operation in the library it calls. need to give more control to the library function.
    Define " more deterministic".
    The thread operation itsellf knows nothing about any "not quite sync with operation in the library". It's up to you how to "synchronize" these two operations.

    Quote Originally Posted by @EE@ View Post
    Victor:
    2. The best way to use serial communication is to place the serial functions code in the secondary thread.

    yes.
    Then just do it!
    Victor Nijegorodov

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

    Re: refresh dialog

    Quote Originally Posted by GCDEF View Post
    If it's an MFC dialog, UpdateData should do it
    Of course it will!
    However, the controls won't be updated until this function:
    Quote Originally Posted by @EE@ View Post
    Have a function as part of a dialog class which has some loops and so on and works. But during its run, the dialog needs its controls , etc. refreshed and update...
    will have finish its work!

    Quote Originally Posted by VictorN View Post
    Define " more deterministic".
    The thread operation itself knows nothing about any "not quite sync with operation in the library". It's up to you how to "synchronize" these two operations.

    Then just do it!
    Victor Nijegorodov

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

    Re: refresh dialog

    Quote Originally Posted by @EE@ View Post
    Have a function as part of a dialog class which has some loops and so on and works. But during its run, the dialog needs its controls , etc. refreshed and update. For reasons can not use worker thread for this function. What's the best way to refresh/update dialog at the same time that the serial processes in this function are running. Without flickering .
    There exists a "simple" way to implement it without using a worker thread. Just have a look at http://www.flounder.com/workerthreads.htm, section "Doing it the obsolete, and hard, way". But I'm afraid it will work slowly and won't avoid flickering.

    Therefore, just read this essay further beginning with the section "The Thread Solution".
    Victor Nijegorodov

  8. #8
    Join Date
    Aug 2019
    Posts
    72

    Re: refresh dialog

    thanks for the link. useful.

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