![]() |
xtd - Reference Guide
0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
|
#include <background_worker.h>
Executes an operation on a separate thread.
Inherits xtd::forms::component.
Public Attributes | |
| event< background_worker, do_work_event_handler > | do_work |
| Occurs when run_worker_async() is called. | |
| event< background_worker, progress_changed_event_handler > | progress_changed |
| Occurs when report_progress(int32_t) is called. | |
| event< background_worker, run_worker_completed_event_handler > | run_worker_completed |
| Occurs when the background operation has completed, has been canceled, or has raised an exception. | |
Public Member Functions | |
| background_worker () | |
| Initializes a new instance of the background_worker class. | |
| void | cancel_async () |
| Requests cancellation of a pending background operation. | |
| bool | cancellation_pending () const |
| Gets a value indicating whether the application has requested cancellation of a background operation. | |
| bool | is_busy () const |
| Gets a value indicating whether the background_worker is running an asynchronous operation. | |
| virtual void | on_do_work (do_work_event_args &e) |
| Raises the background_worker::do_work event. | |
| virtual void | on_progress_changed (const progress_changed_event_args &e) |
| Raises the background_worker::progress_changed event. | |
| virtual void | on_run_worker_completed (const run_worker_completed_event_args &e) |
| Raises the background_worker::run_worker_completed event. | |
| void | report_progress (int32_t percent_progress) |
| Raises the ProgressChanged event. | |
| void | report_progress (int32_t percent_progress, std::any user_state) |
| Raises the ProgressChanged event. | |
| void | run_worker_async () |
| Starts execution of a background operation. | |
| template<typename argument_t > | |
| void | run_worker_async (argument_t argument) |
| Starts execution of a background operation. | |
| bool | worker_reports_progress () const |
| Gets a value indicating whether the background_worker can report progress updates.Gets or sets a value indicating whether the background_worker can report progress updates. | |
| void | worker_reports_progress (bool value) |
| Sets a value indicating whether the background_worker can report progress updates.Gets or sets a value indicating whether the background_worker can report progress updates. | |
| bool | worker_supports_cancellation () const |
| Gets a value indicating whether the background_worker supports asynchronous cancellation. | |
| void | worker_supports_cancellation (bool value) |
| Gets a value indicating whether the background_worker supports asynchronous cancellation. | |
Public Member Functions inherited from xtd::object | |
| object ()=default | |
| Create a new instance of the ultimate base class object. | |
| virtual bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object. | |
| virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type. | |
| template<typename object_t > | |
| std::unique_ptr< object_t > | memberwise_clone () const |
| Gets the type of the current instance. | |
| virtual xtd::ustring | to_string () const noexcept |
| Returns a std::string that represents the current object. | |
Additional Inherited Members | |
Static Public Member Functions inherited from xtd::object | |
| static bool | equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are considered equal. | |
| static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are the same instance. | |
Protected Member Functions inherited from xtd::forms::component | |
| component ()=default | |
| Initialises a new instance of the component class. | |
| virtual bool | can_raise_events () const |
| Gets a value indicating whether the component can raise an event. | |
| bool | design_mode () const |
| Gets a value that indicates whether the component is currently in design mode. | |
| xtd::forms::background_worker::background_worker | ( | ) |
Initializes a new instance of the background_worker class.
| void xtd::forms::background_worker::cancel_async | ( | ) |
Requests cancellation of a pending background operation.
|
inline |
Gets a value indicating whether the application has requested cancellation of a background operation.
|
inline |
Gets a value indicating whether the background_worker is running an asynchronous operation.
|
inlinevirtual |
Raises the background_worker::do_work event.
| e | An event_args that contains the event data. |
|
inlinevirtual |
Raises the background_worker::progress_changed event.
| e | An event_args that contains the event data. |
|
inlinevirtual |
Raises the background_worker::run_worker_completed event.
| e | An event_args that contains the event data. |
| void xtd::forms::background_worker::report_progress | ( | int32_t | percent_progress | ) |
Raises the ProgressChanged event.
| percent_progress | The percentage, from 0 to 100, of the background operation that is complete. |
| void xtd::forms::background_worker::report_progress | ( | int32_t | percent_progress, |
| std::any | user_state | ||
| ) |
Raises the ProgressChanged event.
| percent_progress | The percentage, from 0 to 100, of the background operation that is complete. |
| user_state | A unique object indicating the user state. Returned as the user_state property of the progress_changed_even_args. |
| void xtd::forms::background_worker::run_worker_async | ( | ) |
Starts execution of a background operation.
|
inline |
Starts execution of a background operation.
| argument | A parameter for use by the background operation to be executed in the do_work event handler. |
|
inline |
Gets a value indicating whether the background_worker can report progress updates.Gets or sets a value indicating whether the background_worker can report progress updates.
|
inline |
Sets a value indicating whether the background_worker can report progress updates.Gets or sets a value indicating whether the background_worker can report progress updates.
| value | true if the background_worker supports progress updates; otherwise false. The default is false. |
|
inline |
Gets a value indicating whether the background_worker supports asynchronous cancellation.
|
inline |
Gets a value indicating whether the background_worker supports asynchronous cancellation.
| value | true if the background_worker supports cancellation; otherwise false. The default is false. |