hgoldfish / qtnetworkng

QtNetwork Next Generation. A coroutine based network framework for Qt/C++, with more simpler API than boost::asio.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use timer?

ywwyewenwei opened this issue · comments

There is no need to use QTimer in coroutines, just call Coroutine::sleep() or Coroutine::msleep() instead:

Coroutine::spawn([] {
    while (true) {
        qDebug()<< "hello, there!";
        Coroutine::sleep(1.0);    // or msleep(1000);
    }
});

Thanks a lot.