xtd 1.0.0
Loading...
Searching...
No Matches
background_worker.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../forms_export.hpp"
6#include "component.hpp"
7#include "form.hpp"
11
13namespace xtd {
15 namespace forms {
35 struct data;
36
37 public:
39
45
47 ~background_worker() noexcept;
49
51
55 [[nodiscard]] auto cancellation_pending() const noexcept -> bool;
56
59 [[nodiscard]] auto is_busy() const noexcept -> bool;
60
64 [[nodiscard]] auto worker_reports_progress() const noexcept -> bool;
68 auto worker_reports_progress(bool value) -> void;
69
73 [[nodiscard]] auto worker_supports_cancellation() const noexcept -> bool;
77 auto worker_supports_cancellation(bool value) -> void;
79
81
86 auto cancel_async() -> void;
87
90 virtual auto on_do_work(do_work_event_args& e) -> void;
91
94 virtual auto on_progress_changed(const progress_changed_event_args& e) -> void;
95
99
102 auto run_worker_async() -> void;
103
107 template<typename argument_t>
108 auto run_worker_async(argument_t argument) -> void {
109 argument_(xtd::any_object(argument));
111 }
112
115 auto report_progress(int32 percent_progress) -> void;
116
120 auto report_progress(int32 percent_progress, const xtd::any_object& user_state) -> void;
122
124
129
133
138
139 private:
140 auto argument_(xtd::any_object&& argument) -> void;
141
142 xtd::sptr<data> data_;
143 };
144 }
145}
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
Represents an event.
Definition event.hpp:23
event< background_worker, progress_changed_event_handler > progress_changed
Occurs when report_progress(int32) is called.
Definition background_worker.hpp:132
auto report_progress(int32 percent_progress, const xtd::any_object &user_state) -> void
Raises the ProgressChanged event.
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.
Definition background_worker.hpp:136
auto report_progress(int32 percent_progress) -> void
Raises the ProgressChanged event.
virtual auto on_progress_changed(const progress_changed_event_args &e) -> void
Raises the background_worker::progress_changed event.
background_worker() noexcept
Initializes a new instance of the background_worker class.
auto worker_reports_progress() const noexcept -> bool
Gets a value indicating whether the background_worker can report progress updates....
auto cancellation_pending() const noexcept -> bool
Gets a value indicating whether the application has requested cancellation of a background operation.
auto is_busy() const noexcept -> bool
Gets a value indicating whether the background_worker is running an asynchronous operation.
virtual auto on_run_worker_completed(const run_worker_completed_event_args &e) -> void
Raises the background_worker::run_worker_completed event.
auto cancel_async() -> void
Requests cancellation of a pending background operation.
event< background_worker, do_work_event_handler > do_work
Occurs when run_worker_async() is called.
Definition background_worker.hpp:128
auto run_worker_async() -> void
Starts execution of a background operation.
virtual auto on_do_work(do_work_event_args &e) -> void
Raises the background_worker::do_work event.
auto worker_supports_cancellation() const noexcept -> bool
Gets a value indicating whether the background_worker supports asynchronous cancellation.
Provides the base implementation and enables object sharing between applications.
Definition component.hpp:26
Provides data for the xtd::forms::background_worker::do_work event handler.
Definition do_work_event_args.hpp:23
Provides data for the xtd::forms::background_worker::progress_changed event handler.
Definition progress_changed_event_args.hpp:23
Provides data for the xtd::forms::background_worker::run_worker_completed event handler.
Definition run_worker_completed_event_args.hpp:24
Contains xtd::forms::component class.
Contains xtd::forms::do_work_event_handler event handler.
Contains xtd::forms::form container.
Contains forms_export_ keyword.
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:219
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:197
Contains xtd::forms::progress_changed_event_handler handler.
Contains xtd::forms::run_worker_completed_event_handler handler.