Thread which increments the label value every ms
| 61 | |
| 62 | // Thread which increments the label value every ms |
| 63 | void label_update_thread(GtkLabel *label) |
| 64 | { |
| 65 | int counter = 0; |
| 66 | while (true) { |
| 67 | // Sleep for 1ms |
| 68 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); |
| 69 | counter++; |
| 70 | |
| 71 | // Update the label contents in the UI thread |
| 72 | async::spawn(gtk_scheduler(), [label, counter] { |
| 73 | gtk_label_set_text(label, std::to_string(counter).c_str()); |
| 74 | }); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | int main(int argc, char *argv[]) |
| 79 | { |