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

Shows how to use xtd::delegate::begin_invoke, xtd::delegate::end_invoke and xtd::delegate::invoke methods.

#include <xtd/threading/thread>
#include <xtd/console>
#include <xtd/delegate>
using namespace xtd;
using namespace xtd::threading;
auto main()->int {
auto d1 = delegate<int(ustring)> {[](ustring name)->int {
console::write_line("(Thread {}) Hello {}!", thread::current_thread().managed_thread_id(), name);
return name == "xtd" ? 42 : 24;
}};
auto result = d1.begin_invoke("Gammasoft");
console::write_line("return = {}", d1.invoke("xtd"));
console::write_line("return = {}", d1.end_invoke(result));
}
// This code produces the following output:
//
// (Thread 1) Hello xtd!
// return = 42
// (Thread 4) Hello Gammasoft!
// return = 24
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.h:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10