xtd 0.2.0
Loading...
Searching...
No Matches
timer.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "../core_export.hpp"
7#include "../event.hpp"
9#include "../object.hpp"
10#include "../time_span.hpp"
11#include "../types.hpp"
12
14namespace xtd {
16 namespace timers {
50 class core_export_ timer : public object {
51 struct data;
52 public:
54
69 explicit timer(double interval);
72 explicit timer(const xtd::time_span& interval);
74
76 timer(const timer& timer);
77 timer& operator=(const timer& timer);
78 ~timer();
80
82
88 bool auto_reset() const noexcept;
93 timer& auto_reset(bool value);
94
103 bool enabled() const noexcept;
112 timer& enabled(bool value);
113
122 double interval() const noexcept;
131 timer& interval(double value);
132
157 timer& synchronizing_object(std::nullptr_t value);
159
161
171
173
176 void close();
177
181 void start();
182
186 void stop();
188
189 private:
190 void on_elpased(const elapsed_event_args& e);
191 xtd::sptr<data> data_;
192 };
193 }
194}
Represents an event.
Definition event.hpp:21
Provides a way to synchronously or asynchronously execute a delegate.
Definition isynchronize_invoke.hpp:27
object()=default
Create a new instance of the ultimate base class object.
Represents a time interval.
Definition time_span.hpp:29
Provides data for the xtd::timers::timer::elapsed event.
Definition elapsed_event_args.hpp:18
bool auto_reset() const noexcept
Gets a boolean indicating whether the xtd::timers::timer should raise the xtd::timers::timer::elapsed...
void stop()
Stops raising the xtd::timers::timer::elapsed event by setting xtd::timers::timer::enabled to false.
bool enabled() const noexcept
Gets a value indicating whether the xtd::timers::timer should raise the xtd::timers::timer::elapsed e...
void start()
Starts raising the xtd::timers::timer::elapsed event by setting xtd::timers::timer::enabled to true.
void close()
Releases the resources used by the xtd::timers::timer.
std::optional< xtd::ref< isynchronize_invoke > > synchronizing_object() const noexcept
Gets the object used to marshal event-handler calls that are issued when an interval has elapsed.
timer(const xtd::time_span &interval)
Initializes a new instance of the xtd::timers::timer class, setting the xtd::timers::timer::interval ...
event< timer, elapsed_event_handler > elapsed
Occurs when the interval elapses.
Definition timer.hpp:169
timer(double interval)
Initializes a new instance of the xtd::timers::timer class, and sets the xtd::timers::timer::interval...
double interval() const noexcept
Gets the interval, expressed in milliseconds, at which to raise the xtd::timers::timer::elapsed event...
timer()
Initializes a new instance of the xtd::timers::timer class, and sets all the properties to their init...
Contains core_export_ keyword.
Contains xtd::timers::elapsed_event_handler event handler.
Contains xtd::event event.
xtd::delegate< void(xtd::object &sender, const elapsed_event_args &e)> elapsed_event_handler
Represents the method that will handle the signal events of a xtd::environment.
Definition elapsed_event_handler.hpp:27
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
xtd::reference_wrapper_object< type_t > ref
The xtd::ref object is a reference wrapper.
Definition ref.hpp:25
std::optional< type_t > optional
Represents the optional alias on std::optional.
Definition optional.hpp:26
@ e
The E key.
Definition console_key.hpp:96
Contains xtd::isynchronize_invoke interface.
Provides the xtd::timers::timer component, which allows you to raise an event on a specified interval...
Definition elapsed_event_args.hpp:11
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::object class.
Contains xtd::time_span class.
Contains xtd fundamental types.