xtd 1.0.0
Loading...
Searching...
No Matches
task_delay.cpp

Shows how to use xtd::threading::tasks:task::delay method.

#include <xtd/xtd>
class example {
public:
static auto main() async_ {
auto t = task<int>::run(delegate_ {
task<>::delay(time_span::from_seconds(1.5)).wait();
return 42;
});
co_await t;
console::write_line("Task t status: {}, result: {}", t.status(), t.result());
}
};
startup_(example::main);
// This code produces the following output :
//
// Task t status: ran_to_completion, result: 42
#define delegate_
The declaration of a delegate type is similar to a method signature. It has a return value and any nu...
Definition delegate.hpp:1018
#define startup_(...)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:278