From 2ea480f4f67c399dd59429e1c8727b0365c7ffad Mon Sep 17 00:00:00 2001 From: Arthur Sonzogni Date: Sat, 26 Jun 2021 01:37:18 +0200 Subject: [PATCH] Update example homescreen. Wait for the thread to join. (#129) --- examples/component/homescreen.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/component/homescreen.cpp b/examples/component/homescreen.cpp index 3217ede..abeff69 100644 --- a/examples/component/homescreen.cpp +++ b/examples/component/homescreen.cpp @@ -360,8 +360,9 @@ int main(int argc, const char* argv[]) { }); }); - std::thread update([&screen, &shift]() { - for (;;) { + bool refresh_ui_continue = true; + std::thread refresh_ui([&] { + while(refresh_ui_continue) { using namespace std::chrono_literals; std::this_thread::sleep_for(0.05s); shift++; @@ -370,6 +371,8 @@ int main(int argc, const char* argv[]) { }); screen.Loop(main_renderer); + refresh_ui_continue = false; + refresh_ui.join(); return 0; }