xtd 0.2.0
Loading...
Searching...
No Matches

◆ begin_invoke() [2/3]

template<typename result_t , typename... arguments_t>
async_result xtd::delegate< result_t(arguments_t...)>::begin_invoke ( xtd::async_callback  async_callback,
arguments_t...  arguments 
)

Executes the method represented by the current delegate asynchronously on the thread that the control's underlying handle was created on.

Parameters
async_callbackThe asynchronous callback that will be called at the end of the invocation.
argumentsThe parameter list.
Returns
An async_result_invoke that represents the result of the begin_invoke operation.
Examples
The following examples shows hot tu use xtd::delegate::begin_invoke, xtd::delegate::end_invoke, 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(string)> {[](string 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
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
delegate()=default
Initializes an empty delegate.
@ d1
The 1 key.
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