xtd 0.2.0
Loading...
Searching...
No Matches
timer.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "component.hpp"
6#include <xtd/chrono>
7#include <xtd/event>
8#include <xtd/event_handler>
9#include <xtd/time_span>
10#include <cstdint>
11#include <memory>
12
14namespace xtd {
16 namespace forms {
38 class forms_export_ timer : public component {
39 struct data;
40
41 public:
43
50
52 timer(timer&&) = default;
53 timer(const timer&) = delete;
54 ~timer();
56
58
63 virtual bool enabled() const noexcept;
67 virtual timer& enabled(bool enabled);
68
71 virtual time_span interval() const noexcept;
74 timer& interval(const time_span& interval);
75
79 virtual int32 interval_milliseconds() const noexcept;
83 virtual timer& interval_milliseconds(int32 interval);
85
87
91 void start();
92
95 void stop();
97
99
103 static timer create();
107 static timer create(const time_span& interval);
112 static timer create(const time_span& interval, bool enable);
116 static timer create(int interval_milliseconds);
121 static timer create(int interval_milliseconds, bool enable);
123
125
132
133 protected:
135
139 virtual void on_tick(const event_args& e);
141
142 private:
143 void restart();
144
145 xtd::sptr<data> data_;
146 };
147 }
148}
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.hpp:18
Represents an event.
Definition event.hpp:21
Provides the base implementation and enables object sharing between applications.
Definition component.hpp:25
Implements a timer that raises an event at user-defined intervals. This timer is optimized for use in...
Definition timer.hpp:38
virtual bool enabled() const noexcept
Gets whether the timer is running.
timer()
Initializes a new instance of the timer class.
Contains xtd::forms::component class.
generic_event_handler<> event_handler
Represents the method that will handle an event that has no event data.
Definition event_handler.hpp:32
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::ratio< 1LL, 10000000LL > tick
Represents a tick (1 tick = 100 nanoseconds).
Definition tick.hpp:19
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Represents a time interval.
Definition time_span.hpp:29