Results 1 to 5 of 5

Thread: Worker thread tasks slowdown due to windows minimise and maximise events

  1. #1
    Join Date
    Jun 2008
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Worker thread tasks slowdown due to windows minimise and maximise events

    I have worker thread to receive image data tcp socket and queue up that data.

    Worker thread has more priority that it should not delay receiving data.

    When the UI application is minimised or maximised, it influence the worker thread. A delay is observed in the worker thread.

    I read some article that windows minimise and maximise events are sent using SendMessage. why it disturbs the worker thread tasks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Worker thread tasks slowdown due to windows minimise and maximise events

    Please provide a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2008
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Worker thread tasks slowdown due to windows minimise and maximise events

    Qt Code:
    1. // thread to receive data
    2. CConnectionThread::CConnectionThread(QObject *parent)
    3. : QThread(parent)
    4. {
    5.  
    6. }
    7.  
    8. void CConnectionThread::initConnections()
    9. {
    10.  
    11. m_DataHandler = new CDataHandler(0);
    12. m_DataHandler->initConnections();
    13.  
    14. }
    15.  
    16. void CConnectionThread::run()
    17. {
    18. initConnections();
    19. exec();
    20.  
    21. }
    22.  
    23.  
    24. void CDataHandler::initConnections()
    25. {
    26. m_Connection= new QTcpSocket();
    27.  
    28. m_Connection->connectToHost(ipAddress, portNumber);
    29. m_Connection->waitForConnected(2000);
    30.  
    31. bool ret = connect(m_Connection, SIGNAL(readyRead()), this, SLOT(dataAvailable()));
    32.  
    33.  
    34. }
    35.  
    36. /// data handler class to parse the data from the port and queue up for processing
    37. void CDataHandler::dataAvailable()
    38. {
    39.  
    40. QByteArray* response;
    41. /// read the length of response
    42. /// read the complete response
    43.  
    44. processResponse(response);
    45. delete(response);
    46.  
    47. }
    48.  
    49. void CDataHandler::processResponse(QByteArray* buffer)
    50. {
    51. // get response id
    52. switch(responseId)
    53. {
    54. case IMAGE_DATA:
    55. addToImageQueue(buffer); /// queue of QByteArray* that can be accessible to Both UI and worker thread
    56. break;
    57. case NUMERIC_DATA:
    58. addToNumericQueue(buffer);
    59. emit newDataArrived();
    60. break;
    61. }
    62.  
    63. }
    To copy to clipboard, switch view to plain text mode 

    The worker thread is to read the data from the tcp socket, it should not get affected by any of the UI events. Ideally tcp server should not get slow down.
    Tcp server sends image data for every 1 ms.
    Last edited by wysota; 8th September 2009 at 09:20. Reason: missing [code] tags

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Worker thread tasks slowdown due to windows minimise and maximise events

    This is not a compilable example.

    Even though I can see that the code is probably (I can't know for sure without seeing the bigger image) wrong - your thread does completely nothing, all the data reading takes place in the main thread.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2008
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Worker thread tasks slowdown due to windows minimise and maximise events

    I tried to simulate the issue with sample application. It is a console application. The application simply reads the data from the desired port. (I am not able to send the code for Tcp server, since it is camera device that keep sending image data).

    When I simulate the issue, I fould out that the issue is due to windows manager that takes more time duing minimize and maximize events and caues a delay of 500 ms.

    If the application has to run in real time environment, it should reside in kernal. Or probably need to directly interact with TCP stack.

    Thanks to wysota.
    Attached Files Attached Files

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.