本文整理汇总了C++中TaskManager::startTask方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskManager::startTask方法的具体用法?C++ TaskManager::startTask怎么用?C++ TaskManager::startTask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskManager
的用法示例。
在下文中一共展示了TaskManager::startTask方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sleep_cancel
void TestTaskManager::sleep_cancel()
{
// Set up the manager.
TaskManager *manager = new TaskManager();
QSignalSpy sig_message(manager, SIGNAL(message(QString, QString)));
// Set up a task.
TarsnapTask *task = new TarsnapTask();
QSignalSpy sig_started(task, SIGNAL(started(QVariant)));
task->setCommand("/bin/sh");
task->setArguments(QStringList(get_script("sleep-9-exit-0.sh")));
task->setData(QString("started-9"));
// Start running it, wait a second.
manager->startTask(task);
QTest::qWait(1000);
QVERIFY(sig_started.count() == 1);
QVERIFY(sig_started.takeFirst().at(0).value<QString>() == "started-9");
QVERIFY(sig_message.count() == 0);
// Cancel it
manager->stopTasks(false, true, false);
QVERIFY(sig_message.count() == 1);
QVERIFY(sig_message.takeFirst().at(0).value<QString>()
== "Stopped running tasks.");
QTest::qWait(1000);
// task is deleted by the task manager
delete manager;
}
示例2: main
int main()
{
int turn=CONTINUE;
while(turn!=EXIT)
{
ioHandler io;
int typeSelect;
typeSelect =io.selectType(); //자료형 선택
if( typeSelect<INT || STRING<typeSelect)
break;
if(typeSelect == INT)
{
TaskManager<int> tsk;
turn = tsk.startTask();
}
else if(typeSelect == DOUBLE)
{
TaskManager<double> tsk;
turn = tsk.startTask();
}
else if(typeSelect == RECTANGLE)
{
TaskManager<Rectangle> tsk;
turn = tsk.startTask();
}
else if(typeSelect == STRING)
{
TaskManager<string> tsk;
turn = tsk.startTask();
}
else
turn =EXIT;
}//End of while loop
return 0;
}