xtd 0.2.0
timer.h
Go to the documentation of this file.
1 #pragma once
6 #include "../core_export.h"
7 #include "../event.h"
8 #include "../isynchronize_invoke.h"
9 #include "../object.h"
10 #include "../time_span.h"
11 #include "../types.h"
12 
14 namespace xtd {
16  namespace timers {
48  class core_export_ timer : public object {
49  struct data;
50  public:
52 
62  timer();
67  explicit timer(double interval);
70  explicit timer(const xtd::time_span& interval);
72 
74  timer(const timer& timer);
75  timer& operator=(const timer& timer);
76  ~timer();
78 
80 
86  bool auto_reset() const noexcept;
91  timer& auto_reset(bool value);
92 
101  bool enabled() const noexcept;
110  timer& enabled(bool value);
111 
120  double interval() const noexcept;
129  timer& interval(double value);
130 
139  std::optional<std::reference_wrapper<isynchronize_invoke>> synchronizing_object() const noexcept;
147  timer& synchronizing_object(isynchronize_invoke& value);
155  timer& synchronizing_object(std::nullptr_t value);
157 
159 
169 
171 
174  void close();
175 
179  void start();
180 
184  void stop();
186 
187  private:
188  void on_elpased(const elapsed_event_args& e);
189  std::shared_ptr<data> data_;
190  };
191  }
192 }
Contains xtd::timers::elapsed_event_handler event handler.
Provides a way to synchronously or asynchronously execute a delegate.
Definition: isynchronize_invoke.h:26
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Provides data for the xtd::timers::timer::elapsed event.
Definition: elapsed_event_args.h:18
Represents an event.
Definition: event.h:21
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
Represents a time interval.
Definition: time_span.h:26
event< timer, elapsed_event_handler > elapsed
Occurs when the interval elapses.
Definition: timer.h:167
Generates an event after a set interval, with an option to generate recurring events.
Definition: timer.h:48