I create a thread CreateThread and through it I update the contents of the element in the program. But the update rate is very small, 1 time in 15 seconds. How to make a thread not dependent on the program? At the request of those who wish, I will describe everything in more detail: If you create a stream, it will display a message at high speed in this way:
char *dwThrdParam = "Hello!"; DWORD dwThreadId; HANDLE hThread = CreateThread(0, 0, UpdateList, dwThrdParam, 0, &dwThreadId); ....... DWORD WINAPI UpdateList(LPVOID lParam) { int c = 0; for (;;) { UpdateProcessList(listView, Process); char b[20]; sprintf_s(b, "%s, %d\n",(char*)lParam, c); OutputDebugString(b); c++; } return 0; } But when in a cycle not a flow !!! And I start writing programs that reduce the number of loop passes from several thousand to 30 times per second, then the thread starts displaying the message every 15 seconds. Here is the program loop code:
VSync.Begin(30); while (globalRunning) { if (PeekMessage(&message, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&message); DispatchMessage(&message); } VSync.End(false); } Vsync is based on sleep. An interesting feature if you start to move the window for the title, the flow rate increases many times. For those who are sure that the calculation is:
char buffer[256]; LVITEM lvi; memset(&lvi, 0, sizeof(lvi)); lvi.mask = LVIF_TEXT | LVIF_TEXT; for (int i = 0; i < 10; i++) { lvi.iItem = i; lvi.iSubItem = 0; ListView_InsertItem(listView, &lvi); sprintf_s(buffer, "%d", i); ListView_SetItemText(listView, currentItem, lvi.iSubItem, buffer); }