MCPcopy Create free account
hub / github.com/Amanieu/asyncplusplus / label_update_thread

Function label_update_thread

examples/gtk_scheduler.cpp:63–76  ·  view source on GitHub ↗

Thread which increments the label value every ms

Source from the content-addressed store, hash-verified

61
62// Thread which increments the label value every ms
63void 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
78int main(int argc, char *argv[])
79{

Callers

nothing calls this directly

Calls 1

spawnFunction · 0.85

Tested by

no test coverage detected