[Qt-interest] How to wait <N> ms for file creation/deletion to succeed?

Karl Ruetz karl.ruetz at sototech.com
Mon Dec 29 17:42:01 CET 2008


You can subclass QThread and use the sleep statements:

// This class let's us sleep in seconds, milleseconds, and microseconds
class mySleep : public QThread
{
        public:
                static void sleep(unsigned long secs)
                {
                        QThread::sleep(secs);
                }
                static void msleep(unsigned long msecs)
                {
                        QThread::msleep(msecs);
                }
                static void usleep(unsigned long usecs)
                {
                        QThread::usleep(usecs);
                }
};

Then your call would look like this:

mySleep::sleep(1);

Karl

Robert Hairgrove wrote:
> What is the proper (i.e. platform-independent) way to sleep and poll for 
> a file operation to finish?
>
> I am encrypting/decrypting a file, writing the results to a temporary 
> file, deleting the original file and renaming the temporary file to the 
> one I just deleted. From past experience I know that timing sometimes 
> causes trouble. For example, on Windows you can call the API function 
> sleep(). There are some sleep() functions in QThread, but I think they 
> are not accessible from outside the thread object's code (they are 
> declared static protected).
>
> Thanks!
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>   



More information about the Qt-interest-old mailing list