xtd 0.2.0
Loading...
Searching...
No Matches
xtd::isynchronize_invoke Class Referenceabstract
Inheritance diagram for xtd::isynchronize_invoke:
xtd::interface xtd::forms::control xtd::forms::animation xtd::forms::button_base xtd::forms::collapsible_panel xtd::forms::color_picker xtd::forms::date_time_picker xtd::forms::dot_matrix_display xtd::forms::font_picker xtd::forms::group_box xtd::forms::label xtd::forms::lcd_label xtd::forms::list_control xtd::forms::loading_indicator xtd::forms::month_calendar xtd::forms::picture_box xtd::forms::progress_bar xtd::forms::scroll_bar xtd::forms::scrollable_control xtd::forms::seven_segment_display xtd::forms::splitter xtd::forms::status_bar xtd::forms::tab_control xtd::forms::text_box_base xtd::forms::tool_bar xtd::forms::track_bar

Definition

Provides a way to synchronously or asynchronously execute a delegate.

Namespace
xtd
Library
xtd.core
Remarks
The xtd::isynchronize_invoke interface provides synchronous and asynchronous communication between objects about the occurrence of an event. Objects that implement this interface can receive notification that an event has occurred, and they can respond to queries about the event. In this way, clients can ensure that one request has been processed before they submit a subsequent request that depends on completion of the first.
The xtd::isynchronize_invoke class provides two ways to invoke a process:
  1. Asynchronously, by using the xtd::isynchronize_invoke::begin_invoke method. xtd::isynchronize_invoke::begin_invoke starts a process and then returns immediately. Use xtd::isynchronize_invoke::end_invoke to wait until the process started by xtd::isynchronize_invoke::begin_invoke completes.
  2. Synchronously, by using the xtd::isynchronize_invoke::invoke method. xtd::isynchronize_invoke::invoke starts a process, waits until it completes, and then returns. Use xtd::isynchronize_invoke::invoke when the control's main thread is different from the calling thread to marshal the call to the proper thread.

Public Properties

virtual bool invoke_required () const noexcept=0
 Gets a value indicating whether the caller must call Invoke(Delegate, Object[]) when calling an object that implements this interface.
 

Public Methods

virtual xtd::async_result begin_invoke (delegate< void()> method)=0
 Asynchronously executes the delegate on the thread that created this object.
 
virtual xtd::async_result begin_invoke (delegate< void(std::vector< std::any >)> value, const std::vector< std::any > &args)=0
 Asynchronously executes the delegate on the thread that created this object.
 
virtual std::optional< object_refend_invoke (xtd::async_result async)=0
 Waits until the process started by calling xtd::isynchronize_invoke::begin_invoke completes, and then returns the value generated by the process.
 
virtual std::optional< object_refinvoke (delegate< void()> value)=0
 Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.
 
virtual std::optional< object_refinvoke (delegate< void(std::vector< std::any >)> method, const std::vector< std::any > &args)=0
 Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.
 
virtual std::optional< object_refinvoke (delegate< void(std::vector< std::any >)> method, std::any arg)=0
 Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.
 

Member Function Documentation

◆ invoke_required()

virtual bool xtd::isynchronize_invoke::invoke_required ( ) const
pure virtualnoexcept

Gets a value indicating whether the caller must call Invoke(Delegate, Object[]) when calling an object that implements this interface.

Returns
true if the caller must call xtd::isynchronize_invoke::invoke; otherwise, false.
Remarks
This property determines whether the caller must call xtd::isynchronize_invoke::invoke when making method calls to an object that implements this interface. Such objects are bound to a specific thread and are not thread-safe. If you are calling a method from a different thread, you must use the xtd::isynchronize_invoke::invoke method to marshal the call to the proper thread.

Implemented in xtd::forms::control.

◆ begin_invoke() [1/2]

virtual xtd::async_result xtd::isynchronize_invoke::begin_invoke ( delegate< void()>  method)
pure virtual

Asynchronously executes the delegate on the thread that created this object.

Parameters
methodA xtd::delegate to a method without paramter.
Returns
An xtd::iasync_result interface that represents the asynchronous operation started by calling this method.
Remarks
The method delegate is executed on the thread that created the object, instead of the thread on which xtd::isynchronize_invoke::begin_invoke was called.
The delegate is called asynchronously, and this method returns immediately. You can call this method from any thread. If you need the return value from a process started with this method, call xtd::isynchronize_invoke::end_invoke to get the value.

Implemented in xtd::forms::control, and xtd::forms::control.

◆ begin_invoke() [2/2]

virtual xtd::async_result xtd::isynchronize_invoke::begin_invoke ( delegate< void(std::vector< std::any >)>  value,
const std::vector< std::any > &  args 
)
pure virtual

Asynchronously executes the delegate on the thread that created this object.

Parameters
methodA xtd::delegate to a method that takes parameters of the same number and type that are contained in args.
argsAn array of type Object to pass as arguments to the given method. This can be empty if no arguments are needed.
Returns
An xtd::iasync_result interface that represents the asynchronous operation started by calling this method.
Remarks
The method delegate is executed on the thread that created the object, instead of the thread on which xtd::isynchronize_invoke::begin_invoke was called.
The delegate is called asynchronously, and this method returns immediately. You can call this method from any thread. If you need the return value from a process started with this method, call xtd::isynchronize_invoke::end_invoke to get the value.

Implemented in xtd::forms::control, and xtd::forms::control.

◆ end_invoke()

virtual std::optional< object_ref > xtd::isynchronize_invoke::end_invoke ( xtd::async_result  async)
pure virtual

Waits until the process started by calling xtd::isynchronize_invoke::begin_invoke completes, and then returns the value generated by the process.

Parameters
asyncAn xtd::iasync_result interface that represents the asynchronous operation started by calling xtd::isynchronize_invoke::begin_invoke.
Returns
An xtd::object that represents the return value generated by the asynchronous operation.
Remarks
This method gets the return value of the asynchronous operation represented by the xtd::iasync_result passed by this interface. If the asynchronous operation has not completed, this method will wait until the result is available.

Implemented in xtd::forms::control.

◆ invoke() [1/3]

virtual std::optional< object_ref > xtd::isynchronize_invoke::invoke ( delegate< void()>  value)
pure virtual

Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.

Parameters
methodA xtd::delegate that contains a method to call, in the context of the thread for the control.
Returns
An xtd::object that represents the return value from the delegate being invoked, or null if the delegate has no return value.
Remarks
Unlike xtd::isynchronize_invoke::begin_invoke, this method operates synchronously, that is, it waits until the process completes before returning. Exceptions raised during the call are propagated back to the caller.
Use this method when calling a method from a different thread to marshal the call to the proper thread.

Implemented in xtd::forms::control, and xtd::forms::control.

◆ invoke() [2/3]

virtual std::optional< object_ref > xtd::isynchronize_invoke::invoke ( delegate< void(std::vector< std::any >)>  method,
const std::vector< std::any > &  args 
)
pure virtual

Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.

Parameters
methodA xtd::delegate that contains a method to call, in the context of the thread for the control.
argsAn array of type xtd::object that represents the arguments to pass to the given method. This can be empty if no arguments are needed.
Returns
An xtd::object that represents the return value from the delegate being invoked, or null if the delegate has no return value.
Remarks
Unlike xtd::isynchronize_invoke::begin_invoke, this method operates synchronously, that is, it waits until the process completes before returning. Exceptions raised during the call are propagated back to the caller.
Use this method when calling a method from a different thread to marshal the call to the proper thread.

Implemented in xtd::forms::control, and xtd::forms::control.

◆ invoke() [3/3]

virtual std::optional< object_ref > xtd::isynchronize_invoke::invoke ( delegate< void(std::vector< std::any >)>  method,
std::any  arg 
)
pure virtual

Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.

Parameters
methodA xtd::delegate that contains a method to call, in the context of the thread for the control.
argAn xtd::object that represents the argument to pass to the given method.
Returns
An xtd::object that represents the return value from the delegate being invoked, or null if the delegate has no return value.
Remarks
Unlike xtd::isynchronize_invoke::begin_invoke, this method operates synchronously, that is, it waits until the process completes before returning. Exceptions raised during the call are propagated back to the caller.
Use this method when calling a method from a different thread to marshal the call to the proper thread.

Implemented in xtd::forms::control, and xtd::forms::control.


The documentation for this class was generated from the following file: