xtd 0.2.0
Loading...
Searching...
No Matches
thread_pool.cpp

Shows how to use xtd::threading::thread_pool class.

#include <xtd/xtd>
namespace wait_handle_example {
class program {
public:
static void main() {
// Queue the task.
thread_pool::queue_user_work_item({thread_proc});
console::write_line("Main thread does some work, then sleeps.");
thread::sleep(1000);
console::write_line("Main thread exits.");
}
private:
// This thread procedure performs the task.
static void thread_proc(any_object state_info) {
// No state object was passed to queue_user_work_item, so state_info has no value.
console::write_line("Hello from the thread pool.");
}
};
}
startup_(wait_handle_example::program::main);
// This example produces output similar to the following:
//
// Main thread does some work, then sleeps.
// Hello from the thread pool.
// Main thread exits.
#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