Results 1 to 2 of 2

Thread: Waiting on a thread?

  1. #1
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Waiting on a thread?

    I have a windows QT app where there are essentially 2 threads.

    There is a worker thread that was created via CreateThread().
    This is processing some asynchronously received data.

    There is the GUI thread itself which upon some user action
    initiates a write of some data and then after some time gets called
    back with some rx data by the Thread.

    Therefore I need a way to loop/wait until the callback occurs or
    timeout, but not block the Thread processing while I wait.

    I tried a QWaitCondition and a QMutex, but that seems to block the
    Thread while I'm waiting...

    Seems like I should be able to do this with some combination of the
    QT semaphore/events handlers and without using an actual timer.

    Any suggestions?

    Thanks

    Mark

  2. #2
    Join Date
    Oct 2007
    Location
    Munich, Bavaria
    Posts
    144
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Waiting on a thread?

    To "send" data from the worker thread to the gui-thread you can use Qt's signal and slot mechanism and emit a signal from the wroker thread after you got the data.

    For the timeout mechanism you can use a timer ...

    Just my two cents ....

    Good luck,

    Tom

Similar Threads

  1. Terminating a thread.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 9th July 2007, 11:14
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  3. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  4. simple thread layout question
    By mhoover in forum Qt Programming
    Replies: 1
    Last Post: 12th August 2006, 11:02
  5. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44

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.