xtd - Reference Guide
0.1.1
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. More... | |
event< background_worker, progress_changed_event_handler > | progress_changed |
Occurs when report_progress(int32_t) 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... | |
Public Member Functions | |
background_worker () | |
Initializes a new instance of the background_worker class. More... | |
void | cancel_async () |
Requests cancellation of a pending background operation. More... | |
bool | cancellation_pending () const |
Gets a value indicating whether the application has requested cancellation of a background operation. More... | |
bool | is_busy () const |
Gets a value indicating whether the background_worker is running an asynchronous 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 | report_progress (int32_t percent_progress) |
Raises the ProgressChanged event. More... | |
void | report_progress (int32_t percent_progress, std::any user_state) |
Raises the ProgressChanged 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... | |
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. 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 |
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... | |
Public Member Functions inherited from xtd::object | |
object ()=default | |
Create a new instance of the ultimate base class object. More... | |
virtual 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... | |
template<typename object_t > | |
std::unique_ptr< object_t > | memberwise_clone () const |
Gets the type of the current instance. More... | |
virtual xtd::ustring | to_string () const noexcept |
Returns a std::string that represents the current object. More... | |
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. 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 ()=default | |
Initialises a new instance of the component class. More... | |
virtual bool | can_raise_events () const |
Gets a value indicating whether the component can raise an event. More... | |
bool | design_mode () const |
Gets a value that indicates whether the component is currently in design mode. More... | |
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. |