Generates an event after a set interval, with an option to generate recurring events.
Constructors | |
| timer () | |
| Initializes a new instance of the xtd::timers::timer class, and sets all the properties to their initial values. More... | |
| timer (double interval) | |
| Initializes a new instance of the xtd::timers::timer class, and sets the xtd::timers::timer::interval property to the specified number of milliseconds. More... | |
| timer (const xtd::time_span &interval) | |
| Initializes a new instance of the xtd::timers::timer class, setting the xtd::timers::timer::interval property to the specified period. More... | |
Properties | |
| bool | auto_reset () const noexcept |
| Gets a boolean indicating whether the xtd::timers::timer should raise the xtd::timers::timer::elapsed event only once (false) or repeatedly (true). More... | |
| timer & | auto_reset (bool value) |
| Sets a boolean indicating whether the xtd::timers::timer should raise the xtd::timers::timer::elapsed event only once (false) or repeatedly (true). More... | |
| bool | enabled () const noexcept |
| Gets a value indicating whether the xtd::timers::timer should raise the xtd::timers::timer::elapsed event. More... | |
| timer & | enabled (bool value) |
| Sets a value indicating whether the xtd::timers::timer should raise the xtd::timers::timer::elapsed event. More... | |
| double | interval () const noexcept |
| Gets the interval, expressed in milliseconds, at which to raise the xtd::timers::timer::elapsed event. More... | |
| timer & | interval (double value) |
| Sets the interval, expressed in milliseconds, at which to raise the xtd::timers::timer::elapsed event. More... | |
| std::optional< std::reference_wrapper< isynchronize_invoke > > | synchronizing_object () const noexcept |
| Gets the object used to marshal event-handler calls that are issued when an interval has elapsed. More... | |
| timer & | synchronizing_object (isynchronize_invoke &value) |
| Sets the object used to marshal event-handler calls that are issued when an interval has elapsed. More... | |
| timer & | synchronizing_object (std::nullptr_t value) |
| Resets the object used to marshal event-handler calls that are issued when an interval has elapsed. More... | |
Events | |
| event< timer, elapsed_event_handler > | elapsed |
| Occurs when the interval elapses. More... | |
Methods | |
| void | close () |
| Releases the resources used by the xtd::timers::timer. More... | |
| void | start () |
| Starts raising the xtd::timers::timer::elapsed event by setting xtd::timers::timer::enabled to true. More... | |
| void | stop () |
| Stops raising the xtd::timers::timer::elapsed event by setting xtd::timers::timer::enabled to false. More... | |
Additional Inherited Members | |
Public Member Functions inherited from xtd::object | |
| object ()=default | |
| Create a new instance of the ultimate base class object. More... | |
| bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object. More... | |
| virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type. More... | |
| virtual type_object | get_type () const noexcept |
| Gets the type of the current instance. More... | |
| template<typename object_t > | |
| std::unique_ptr< object_t > | memberwise_clone () const noexcept |
| Creates a shallow copy of the current object. More... | |
| virtual xtd::ustring | to_string () const noexcept |
| Returns a sxd::ustring that represents the current object. More... | |
Static Public Member Functions inherited from xtd::object | |
| static bool | equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are considered equal. More... | |
| static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are the same instance. More... | |
| xtd::timers::timer::timer | ( | ) |
Initializes a new instance of the xtd::timers::timer class, and sets all the properties to their initial values.
| Property | Initial alue |
|---|---|
| xtd::timers::timer::auto_reset | true |
| xtd::timers::timer::enabled | false |
| xtd::timers::timer::nterval | 100 milliseconds |
| xtd::timers::timer::synchronizing_object | std::nullopt |
|
explicit |
Initializes a new instance of the xtd::timers::timer class, and sets the xtd::timers::timer::interval property to the specified number of milliseconds.
| interval | The time, in milliseconds, between events. The value must be greater than zero and less than or equal to int32_object::max_value. |
| d::argument_exception | The value of the interval parameter is less than or equal to zero, or greater than int32_object::max_value. |
|
explicit |
Initializes a new instance of the xtd::timers::timer class, setting the xtd::timers::timer::interval property to the specified period.
| interval | The time between events. The value in milliseconds must be greater than zero and less than or equal to int32_object::max_value. |
|
noexcept |
Gets a boolean indicating whether the xtd::timers::timer should raise the xtd::timers::timer::elapsed event only once (false) or repeatedly (true).
| timer& xtd::timers::timer::auto_reset | ( | bool | value | ) |
Sets a boolean indicating whether the xtd::timers::timer should raise the xtd::timers::timer::elapsed event only once (false) or repeatedly (true).
| value | true if the xtd::timers::timer should raise the xtd::timers::timer::elapsed event each time the interval elapses; false if it should raise the xtd::timers::timer::elapsed event only once, after the first time the interval elapses. The default is true. |
| void xtd::timers::timer::close | ( | ) |
Releases the resources used by the xtd::timers::timer.
|
noexcept |
Gets a value indicating whether the xtd::timers::timer should raise the xtd::timers::timer::elapsed event.
| xtd::object_closed_exception | This property cannot be set because the timer has been closed. |
| xtd::argument_exception | The xtd::timers::timer::interval property was set to a value greater than xtd::int32_object::max_value before the timer was enabled. |
| timer& xtd::timers::timer::enabled | ( | bool | value | ) |
Sets a value indicating whether the xtd::timers::timer should raise the xtd::timers::timer::elapsed event.
| value | true if the xtd::timers::timer should raise the xtd::timers::timer::elapsed event; otherwise, false. The default is false. |
| xtd::object_closed_exception | This property cannot be set because the timer has been closed. |
| xtd::argument_exception | The xtd::timers::timer::interval property was set to a value greater than xtd::int32_object::max_value before the timer was enabled. |
|
noexcept |
Gets the interval, expressed in milliseconds, at which to raise the xtd::timers::timer::elapsed event.
| xtd::argument_exception | The interval is less than or equal to zero. -or The interval is greater than xtd::int32_object::max_value. |
| timer& xtd::timers::timer::interval | ( | double | value | ) |
Sets the interval, expressed in milliseconds, at which to raise the xtd::timers::timer::elapsed event.
| value | The time, in milliseconds, between xtd::timers::timer::elapsed events. The value must be greater than zero, and less than or equal to xtd::int32_object::max_value. The default is 100 milliseconds. |
| xtd::argument_exception | The interval is less than or equal to zero. -or The interval is greater than xtd::int32_object::max_value. |
| void xtd::timers::timer::start | ( | ) |
Starts raising the xtd::timers::timer::elapsed event by setting xtd::timers::timer::enabled to true.
| void xtd::timers::timer::stop | ( | ) |
Stops raising the xtd::timers::timer::elapsed event by setting xtd::timers::timer::enabled to false.
|
noexcept |
Gets the object used to marshal event-handler calls that are issued when an interval has elapsed.
| timer& xtd::timers::timer::synchronizing_object | ( | isynchronize_invoke & | value | ) |
Sets the object used to marshal event-handler calls that are issued when an interval has elapsed.
| value | The xtd::isynchronize_invoke representing the object used to marshal the event-handler calls that are issued when an interval has elapsed. The default is std::nullopt. |
| timer& xtd::timers::timer::synchronizing_object | ( | std::nullptr_t | value | ) |
Resets the object used to marshal event-handler calls that are issued when an interval has elapsed.
| value | nullptr. |
| event<timer, elapsed_event_handler> xtd::timers::timer::elapsed |
Occurs when the interval elapses.