Executes an operation on a separate thread.
Constructors | |
| background_worker () noexcept | |
| Initializes a new instance of the background_worker class. More... | |
Properties | |
| bool | cancellation_pending () const noexcept |
| Gets a value indicating whether the application has requested cancellation of a background operation. More... | |
| bool | is_busy () const noexcept |
| Gets a value indicating whether the background_worker is running an asynchronous operation. More... | |
| bool | worker_reports_progress () const noexcept |
| 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. More... | |
| 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. More... | |
| bool | worker_supports_cancellation () const noexcept |
| Gets a value indicating whether the background_worker supports asynchronous cancellation. More... | |
| void | worker_supports_cancellation (bool value) |
| Gets a value indicating whether the background_worker supports asynchronous cancellation. More... | |
Methods | |
| void | cancel_async () |
| Requests cancellation of a pending background operation. More... | |
| virtual void | on_do_work (do_work_event_args &e) |
| Raises the background_worker::do_work event. More... | |
| virtual void | on_progress_changed (const progress_changed_event_args &e) |
| Raises the background_worker::progress_changed event. More... | |
| virtual void | on_run_worker_completed (const run_worker_completed_event_args &e) |
| Raises the background_worker::run_worker_completed event. More... | |
| void | run_worker_async () |
| Starts execution of a background operation. More... | |
| template<typename argument_t > | |
| void | run_worker_async (argument_t argument) |
| Starts execution of a background operation. More... | |
| void | report_progress (int32 percent_progress) |
| Raises the ProgressChanged event. More... | |
| void | report_progress (int32 percent_progress, std::any user_state) |
| Raises the ProgressChanged event. More... | |
Events | |
| event< background_worker, do_work_event_handler > | do_work |
| Occurs when run_worker_async() is called. More... | |
| event< background_worker, progress_changed_event_handler > | progress_changed |
| Occurs when report_progress(int32) is called. More... | |
| 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. More... | |
Additional Inherited Members | |
Public Member Functions inherited from xtd::object | |
| object ()=default | |
| Create a new instance of the ultimate base class object. More... | |
| bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object. More... | |
| virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type. More... | |
| virtual type_object | get_type () const noexcept |
| Gets the type of the current instance. More... | |
| template<typename object_t > | |
| std::unique_ptr< object_t > | memberwise_clone () const noexcept |
| Creates a shallow copy of the current object. More... | |
| virtual xtd::ustring | to_string () const noexcept |
| Returns a sxd::ustring that represents the current object. More... | |
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. More... | |
| static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are the same instance. More... | |
Protected Member Functions inherited from xtd::forms::component | |
| component () | |
| Initialises a new instance of the component class. More... | |
| virtual bool | can_raise_events () const noexcept |
| Gets a value indicating whether the component can raise an event. More... | |
| bool | design_mode () const noexcept |
| Gets a value that indicates whether the component is currently in design mode. More... | |
|
noexcept |
Initializes a new instance of the background_worker class.
| void xtd::forms::background_worker::cancel_async | ( | ) |
Requests cancellation of a pending background operation.
|
noexcept |
Gets a value indicating whether the application has requested cancellation of a background operation.
|
noexcept |
Gets a value indicating whether the background_worker is running an asynchronous operation.
|
virtual |
Raises the background_worker::do_work event.
| e | An event_args that contains the event data. |
|
virtual |
Raises the background_worker::progress_changed event.
| e | An event_args that contains the event data. |
|
virtual |
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 | percent_progress | ) |
Raises the ProgressChanged event.
| percent_progress | The percentage, from 0 to 100, of the background operation that is complete. |
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.
| xtd::invalid_operaton_exception | xtd::background_worker::is_busy is true; |
|
inline |
Starts execution of a background operation.
| argument | A parameter for use by the background operation to be executed in the xtd::forms::background_worker::do_work event handler. |
| xtd::invalid_operaton_exception | xtd::background_worker::is_busy is true; |
|
noexcept |
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 xtd::forms::background_worker::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.
| value | true if the background_worker supports progress updates; otherwise false. The default is false. |
|
noexcept |
Gets a value indicating whether the background_worker supports asynchronous cancellation.
| void xtd::forms::background_worker::worker_supports_cancellation | ( | bool | value | ) |
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. |
| event<background_worker, do_work_event_handler> xtd::forms::background_worker::do_work |
Occurs when run_worker_async() is called.
| event<background_worker, progress_changed_event_handler> xtd::forms::background_worker::progress_changed |
Occurs when report_progress(int32) is called.
| event<background_worker, run_worker_completed_event_handler> xtd::forms::background_worker::run_worker_completed |
Occurs when the background operation has completed, has been canceled, or has raised an exception.