[Qt-interest] QThread::sleep static protected

Patric userqt at gmail.com
Sun May 31 15:17:27 CEST 2009


:) Thank you Karol. Actually, I'm going to use different thread for this 
request, so I don't think the UI will be affected.
I hope the method I mentioned will do the job.

Regards,
Patric

----- Original Message ----- 
From: "Karol Krizka" <kkrizka at gmail.com>
To: "Patric" <userqt at gmail.com>
Sent: Sunday, May 31, 2009 4:06 PM
Subject: Re: [Qt-interest] QThread::sleep static protected


> On Sun, May 31, 2009 at 2:59 PM, Patric <userqt at gmail.com> wrote:
>> Well, I'm sending some UDP packages on the wire. And I need if there is 
>> no
>> response 5 seconds, the function to exit with error code. That's why I 
>> need
>> a timeout. The application is UI interface.
>>
> So yes, to me it seems that you do not want to use a standard sleep
> function. While you'll be waiting for the response, the UI will remain
> frozen from all updates for 5 seconds. Even simple ones like
> repainting the window. I don't have much experience with network code,
> so I can't help you with the best common approach is.
>
> --
> Cheers,
> Karol Krizka
> http://www.krizka.net
>
>> Regards,
>> Patric
>> ----- Original Message ----- From: "Karol Krizka" <kkrizka at gmail.com>
>> To: "Patric" <userqt at gmail.com>
>> Cc: <qt-interest at trolltech.com>
>> Sent: Sunday, May 31, 2009 3:48 PM
>> Subject: Re: [Qt-interest] QThread::sleep static protected
>>
>>
>>> Hi there,
>>>
>>> 2009/5/31 Patric <userqt at gmail.com>:
>>>>
>>>> Hello,
>>>> I'm trying to sleep my thread for 5 seconds and I tried to use
>>>> QThread::sleep. But it's protected and it seems I can't use it.
>>>> QThread::sleep(5); for example.
>>>>
>>> A google search turns up this thread:
>>> http://lists.trolltech.com/qt-interest/2007-01/thread00133-0.html
>>>
>>> It seems that you will have to implement your own sleep function.
>>> However, there is also an earlier thread:
>>> http://lists.trolltech.com/qt-interest/2005-08/thread00071-0.html
>>> According to it, it is not a good idea to pause an interactive
>>> application like those build with Qt, and I tend to agree with that.
>>> However, that argument does not work with console applications, which
>>> Qt supports. If that is the case, did you think about using the
>>> standard C sleep() function?
>>>
>>>> What's the best way to pause my program for 5 seconds, I'm trying to
>>>> implement a timeout.
>>>>
>>> What do you mean you're trying to implement a timeout? Are you trying
>>> to do some task (ei: connect somewhere), and if it does not succeed in
>>> a certain time, then kill it and inform the user? If so, I don't think
>>> pausing the program for 5 seconds is a good idea. What if the task
>>> completes before 5 seconds are up? Plus this will keep your
>>> application in an unresponsive state (including no redraws).
>>>
>>> --
>>> Cheers,
>>> Karol Krizka
>>> http://www.krizka.net
>>>
>>>
>>> __________ Information from ESET NOD32 Antivirus, version of virus
>>> signature database 4098 (20090522) __________
>>>
>>> The message was checked by ESET NOD32 Antivirus.
>>>
>>> http://www.eset.com
>>>
>>>
>>>
>>
>>
>> __________ Information from ESET NOD32 Antivirus, version of virus 
>> signature
>> database 4098 (20090522) __________
>>
>> The message was checked by ESET NOD32 Antivirus.
>>
>> http://www.eset.com
>>
>>
>>
>>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus 
> signature database 4098 (20090522) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
> 


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4098 (20090522) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com






More information about the Qt-interest-old mailing list