Results 1 to 6 of 6

Thread: Why isn't QTimer asynchronous?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Why isn't QTimer asynchronous?

    Quote Originally Posted by Hossein View Post
    By the way Is it not more logical to make QTimer run its own thread of execution in essence?
    That would just make things unnecessarily complex for the common use case where you just want to trigger a function every X milliseconds.
    Since it is easy enough to move a timer to a secondary thread, there is no need to make the common case more complex by forcing multithreading into the application.

    Your example demonstrates actually very well that multithreading is something one has to explicitly thing about.

    The primary objective should always be to keep the UI from becoming unresponsive. Blocking its thread with a long running operation is very bad for that goal.
    Instead of looking for a way to keep the timer responsive, you should be looking at keeping the UI responsive.

    The part that should run in the secondary thread is the part that blocks, the code that takes long to execute.


    Cheers,
    _

  2. The following user says thank you to anda_skoa for this useful post:

    Hossein (11th October 2015)

  3. #2
    Join Date
    Sep 2012
    Location
    Iran
    Posts
    34
    Thanks
    33
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Why isn't QTimer asynchronous?

    Thanks, thats pretty reasonable,

Similar Threads

  1. Replies: 1
    Last Post: 25th October 2012, 19:47
  2. Replies: 15
    Last Post: 4th August 2012, 19:11
  3. QtSoap with asynchronous web service
    By TorAn in forum Qt Programming
    Replies: 0
    Last Post: 24th August 2010, 01:05
  4. asynchronous thread.
    By wookoon in forum Newbie
    Replies: 1
    Last Post: 7th July 2010, 07:16
  5. asynchronous vs. synchroneous
    By timmu in forum Qt Programming
    Replies: 4
    Last Post: 28th August 2009, 10:48

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.