xtd 0.2.0
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 bool cancellation_pending() const noexcept;
56
59 bool is_busy() const noexcept;
60
64 bool worker_reports_progress() const noexcept;
68 void worker_reports_progress(bool value);
69
73 bool worker_supports_cancellation() const noexcept;
79
81
87
91
95
99
103
107 template<class argument_t>
108 void run_worker_async(argument_t argument) {
109 argument_(xtd::any_object(argument));
111 }
112
115 void report_progress(int32 percent_progress);
116
120 void report_progress(int32 percent_progress, const xtd::any_object& user_state);
122
124
129
133
138
139 private:
140 void argument_(xtd::any_object&& argument);
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:21
event< background_worker, progress_changed_event_handler > progress_changed
Occurs when report_progress(int32) is called.
Definition background_worker.hpp:132
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
bool worker_supports_cancellation() const noexcept
Gets a value indicating whether the background_worker supports asynchronous cancellation.
bool cancellation_pending() const noexcept
Gets a value indicating whether the application has requested cancellation of a background operation.
void report_progress(int32 percent_progress)
Raises the ProgressChanged event.
void run_worker_async()
Starts execution of a background operation.
virtual void on_do_work(do_work_event_args &e)
Raises the background_worker::do_work event.
virtual void on_run_worker_completed(const run_worker_completed_event_args &e)
Raises the background_worker::run_worker_completed event.
background_worker() noexcept
Initializes a new instance of the background_worker class.
void cancel_async()
Requests cancellation of a pending background operation.
bool worker_reports_progress() const noexcept
Gets a value indicating whether the background_worker can report progress updates....
bool is_busy() const noexcept
Gets a value indicating whether the background_worker is running an asynchronous operation.
event< background_worker, do_work_event_handler > do_work
Occurs when run_worker_async() is called.
Definition background_worker.hpp:128
virtual void on_progress_changed(const progress_changed_event_args &e)
Raises the background_worker::progress_changed event.
void report_progress(int32 percent_progress, const xtd::any_object &user_state)
Raises the ProgressChanged event.
component()
Initialises a new instance of the component class.
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
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
@ e
The E key.
Definition keys.hpp:207
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 const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
Contains xtd::forms::progress_changed_event_handler handler.
Contains xtd::forms::run_worker_completed_event_handler handler.