I am looking for a good way to check a value within a period of time.
In principle, the code below works.
Are there possibilities with CTime, MFC functions?
Why is this written?
atlTraceGeneral
Is that the TRACE macro?
time\timedlg.cpp(186) : atlTraceGeneral - 0
time\timedlg.cpp(193) : atlTraceGeneral - 16:10:01
time\timedlg.cpp(186) : atlTraceGeneral - 1
time\timedlg.cpp(193) : atlTraceGeneral - 16:10:02
time\timedlg.cpp(186) : atlTraceGeneral - 2
time\timedlg.cpp(193) : atlTraceGeneral - 16:10:03
time\timedlg.cpp(186) : atlTraceGeneral - 3
time\timedlg.cpp(193) : atlTraceGeneral - 16:10:04
time\timedlg.cpp(186) : atlTraceGeneral - 4
time\timedlg.cpp(193) : atlTraceGeneral - 16:10:05
time\timedlg.cpp(186) : atlTraceGeneral - 5
time\timedlg.cpp(193) : atlTraceGeneral - 16:10:06
time\timedlg.cpp(186) : atlTraceGeneral - 6
time\timedlg.cpp(193) : atlTraceGeneral - 16:10:08
time\timedlg.cpp(186) : atlTraceGeneral - 7
time\timedlg.cpp(193) : atlTraceGeneral - 16:10:09
void CTimeDlg::OnBnClickedButtonTime()
{
auto now = std::chrono::steady_clock::now;
using namespace std::chrono_literals;
auto work_duration = 15s;
auto start = now();
int i = 0;
TRACE("START");
CString sTime;
CString t = CTime::GetCurrentTime().Format("%H:%M:%S");
TRACE1("%s\n", t);
bool resultMES = false;
while ((now() - start) < work_duration)
{
TRACE1("%d\n", i);
// Check value is true, then break
Sleep(1000);
t = CTime::GetCurrentTime().Format("%H:%M:%S");
TRACE1("%s\n", t);
i++;
};
TRACE("END");
t = CTime::GetCurrentTime().Format("%H:%M:%S");
TRACE1("%s\n", t);
}