xtd 0.2.0
Loading...
Searching...
No Matches
background_worker.h
Go to the documentation of this file.
1
4#pragma once
5#include "../forms_export.h"
6#include "component.h"
7#include "form.h"
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;
77 void worker_supports_cancellation(bool value);
79
81
86 void cancel_async();
87
90 virtual void on_do_work(do_work_event_args& e);
91
94 virtual void on_progress_changed(const progress_changed_event_args& e);
95
98 virtual void on_run_worker_completed(const run_worker_completed_event_args& e);
99
102 void run_worker_async();
103
107 template<typename argument_t>
108 void run_worker_async(argument_t argument) {
109 argument_(std::any(argument));
110 run_worker_async();
111 }
112
115 void report_progress(int32 percent_progress);
116
120 void report_progress(int32 percent_progress, std::any user_state);
122
124
129
133
138
139 private:
140 void argument_(std::any&& argument);
141
142 xtd::sptr<data> data_;
143 };
144 }
145}
Represents an event.
Definition event.h:21
Executes an operation on a separate thread.
Definition background_worker.h:34
event< background_worker, progress_changed_event_handler > progress_changed
Occurs when report_progress(int32) is called.
Definition background_worker.h: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.h:136
void report_progress(int32 percent_progress)
Raises the ProgressChanged event.
background_worker() noexcept
Initializes a new instance of the background_worker class.
event< background_worker, do_work_event_handler > do_work
Occurs when run_worker_async() is called.
Definition background_worker.h:128
void report_progress(int32 percent_progress, std::any user_state)
Raises the ProgressChanged event.
Provides the base implementation and enables object sharing between applications.
Definition component.h:25
Provides data for the xtd::forms::background_worker::do_work event handler.
Definition do_work_event_args.h:23
Provides data for the xtd::forms::background_worker::progress_changed event handler.
Definition progress_changed_event_args.h:23
Provides data for the xtd::forms::background_worker::run_worker_completed event handler.
Definition run_worker_completed_event_args.h:24
Contains xtd::forms::component class.
Contains xtd::forms::do_work_event_handler event handler.
#define forms_export_
Define shared library export.
Definition forms_export.h:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.h:25
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::forms::progress_changed_event_handler event handler.
Contains xtd::forms::run_worker_completed_event_handler event handler.
Contains xtd::forms::style_sheets::form alias.