none
How to improve real time updating of MFC dialogue's data ? RRS feed

  • Question

  • In my project, I get a lot of data from CAN, and want to display them in a List table which is created in a dialogue class, as faster as better

    Unfortunately, I found the updating  one item of the list table takes  about 2~3 ms ,  I exptect it less than 1 ms,  even 500 us 

    I have tried multiple threads method for two days, BUT failed, PostThreadMessage() lost messages!

    I have tried to use timer counter, the updating speed not get better;

    Q1, Does MFC 's  message handlers are mutiple threads? if so, I would split the data's display on several messages handlers 

    Q2, For Window or MFC,  1ms time response is a limit? which can't be more faster? 

    Q3, Is there any method to speed up updating data of a dialogue in MFC?  I have chekced the some window's based program,such as VECTOR CANoe, they updates data on window's UI very quickly .

    Thanks  


    • Edited by hitbuyi Tuesday, October 29, 2019 12:05 PM
    Tuesday, October 29, 2019 12:00 PM

Answers

  • Windows have thread affinity.  They are tied to the thread that created them and that thread also has its own message queue.  Therefore, user interface code is inherently single threaded.

    PostThreadMessage posts a windows message without specifying an HWND to a thread's input queue.  Since there is no HWND, such messages cannot be dispatched to a window.  That is why they are "lost".

    MFC message handling is not multi-threaded.

    One way to speed things up is to avoid unnecessary redrawing of a window.  For example, if you are updating multiple items in a list control you can use WM_SETREDRAW to prevent the control from redrawing itself until all updates have been made.

    • Marked as answer by hitbuyi Wednesday, October 30, 2019 4:45 AM
    Tuesday, October 29, 2019 1:04 PM

All replies

  • Windows have thread affinity.  They are tied to the thread that created them and that thread also has its own message queue.  Therefore, user interface code is inherently single threaded.

    PostThreadMessage posts a windows message without specifying an HWND to a thread's input queue.  Since there is no HWND, such messages cannot be dispatched to a window.  That is why they are "lost".

    MFC message handling is not multi-threaded.

    One way to speed things up is to avoid unnecessary redrawing of a window.  For example, if you are updating multiple items in a list control you can use WM_SETREDRAW to prevent the control from redrawing itself until all updates have been made.

    • Marked as answer by hitbuyi Wednesday, October 30, 2019 4:45 AM
    Tuesday, October 29, 2019 1:04 PM
  • If SetRedraw() doesn't work as suggested, you ucoudl try to use a "virtual list view".

    http://codexpert.ro/blog/2013/11/04/fill-a-list-with-large-amount-of-data-part-2/

    -Seetharam

    Tuesday, October 29, 2019 1:37 PM
  •  good resource,I'll have a try
    Wednesday, October 30, 2019 4:50 AM