Shows how to use xtd::threading::thread class.
#include <xtd/xtd>
class thread_example {
public:
static void thread_proc() {
for (auto i = 0; i < 10; ++i) {
console::write_line("thread_proc: {0}", i);
thread::sleep(0);
}
}
static void main() {
console::write_line("Main thread: Start a second thread.");
auto t = thread {thread_proc};
t.start();
for (auto i = 0; i < 4; ++i) {
console::write_line("Main thread: Do some work.");
thread::sleep(0);
}
console::write_line("Main thread: Call join(), to wait until thread_proc ends.");
t.join();
console::write_line("Main thread: thread_proc.join has returned. Press Enter to end program.");
console::read_line();
}
};
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:168