Shows how to use xtd::environment::program_stopped event.
#include <xtd/threading/thread>
#include <xtd/console>
#include <xtd/environment>
#include <xtd/startup>
namespace environment_program_exit_example {
public:
environment::program_exit += [](auto e) {
console::write_line("The program is stopped {}ly!", e.exit_mode());
};
console::write_line("Start");
auto do_something_thread =
thread{[] {
for (auto step = 0; step < 50; ++step) {
console::write('.');
threading::thread::sleep(100_ms);
}
console::write_line();
}};
do_something_thread.start();
do_something_thread.join();
console::write_line("End");
if (args.
size() == 1 && args[0] ==
"exit") {
console::write_line("Before environment::exit");
environment::exit(exit_status::success);
console::write_line("After environment::exit");
}
else if (args.
size() == 1 && args[0] ==
"quick_exit") {
console::write_line("Before environment::quick_exit");
environment::quick_exit(exit_status::success);
console::write_line("After environment::quick_exit");
}
}
};
}
startup_(environment_program_exit_example::program::main);
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:71
virtual size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(xtd::collections::generic::list::...
Definition list.hpp:364
Creates and controls a thread, sets its priority, and gets its status.
Definition thread.hpp:43
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:37
#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:175
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10