xtd 0.2.0
Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
1
4#pragma once
5#include "component.h"
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 {
36 class forms_export_ timer : public component {
37 struct data;
38
39 public:
41
48
50 timer(timer&&) = default;
51 timer(const timer&) = delete;
52 ~timer();
54
56
61 virtual bool enabled() const noexcept;
65 virtual timer& enabled(bool enabled);
66
69 virtual time_span interval() const noexcept;
72 timer& interval(const time_span& interval);
73
77 virtual int32 interval_milliseconds() const noexcept;
81 virtual timer& interval_milliseconds(int32 interval);
83
85
89 void start();
90
93 void stop();
95
97
101 static timer create();
105 static timer create(const time_span& interval);
110 static timer create(const time_span& interval, bool enable);
114 static timer create(int interval_milliseconds);
119 static timer create(int interval_milliseconds, bool enable);
121
123
130
131 protected:
133
137 virtual void on_tick(const event_args& e);
139
140 private:
141 void restart();
142
143 std::shared_ptr<data> data_;
144 };
145 }
146}
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.h:18
Represents an event.
Definition event.h:21
Provides the base implementation and enables object sharing between applications.
Definition component.h:23
Implements a timer that raises an event at user-defined intervals. This timer is optimized for use in...
Definition timer.h:36
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.h:32
#define forms_export_
Define shared library export.
Definition forms_export.h:13
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
std::ratio< 1LL, 10000000LL > tick
Represents a tick (1 tick = 100 nanoseconds).
Definition tick.h:19
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
Represents a time interval.
Definition time_span.h:26