C# waitone-like functionality?
-
The function I want to do may not be exactly the same as waitone, but for example it repeats some action in a for loop.
The code inside the for loop repeats continuously, but I want to wait until a specific signal is received.Is there a way to stop repeating until a specific signal is received and resume when the signal is received?
-
@IknowQT said in C# waitone-like functionality?:
You have to process this as iteratively as a loop
No, you don't.
Implement it properly using signals/slots, then you do not need such a loop. -
@IknowQT You should not have any long lasting loops when using event driven frameworks like Qt! Else signals/slots will not work!
What you can do: use a timer, in the slot connected to the timout signal you put the code you currently have in that loop. In the slot you connect to the signal you described you set a flag variable which you then check in the timout slot to decide whether you should execute the code or not. -
for (int nCnt = 1; nCnt <= m_pDataModel->rowCount(); nCnt++) { // [ 샘플을 넣으세요 Msg 출력] { wMessageBox msg(QString::fromLocal8Bit("샘플을 삽입하십시오"), this); } cGlobalParam::SendMeasureStart(ModeTypes::StandardCurve); if (data) { qDebug() << "data1 : " << data; float fa = data->ABS; float ft = data->Trans; } } break;
cGlobalParam::SendMeasureStart(ModeTypes::StandardCurve) is a function that tells the measurement start from tcp.
After clicking on the message, it sends a start signal and when a packet indicating that the action is over is received, it tries to process the data.
You have to process this as iteratively as a loop. And since there is time to measure, the next loop can be performed only when the measurement complete signal is received.Can I use it as a qtimer in this case as well?
-
@IknowQT said in C# waitone-like functionality?:
You have to process this as iteratively as a loop
No, you don't.
Implement it properly using signals/slots, then you do not need such a loop.