Generates an event after a set interval, with an option to generate recurring events.
Public Events | |
| event< timer, elapsed_event_handler > | elapsed | 
| Occurs when the interval elapses.   | |
Public Constructors | |
| timer () | |
| Initializes a new instance of the xtd::timers::timer class, and sets all the properties to their initial values.   | |
| 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.   | |
| 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.   | |
Public 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).   | |
| 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).   | |
| bool | enabled () const noexcept | 
| Gets a value indicating whether the xtd::timers::timer should raise the xtd::timers::timer::elapsed event.   | |
| timer & | enabled (bool value) | 
| Sets a value indicating whether the xtd::timers::timer should raise the xtd::timers::timer::elapsed event.   | |
| double | interval () const noexcept | 
| Gets the interval, expressed in milliseconds, at which to raise the xtd::timers::timer::elapsed event.   | |
| timer & | interval (double value) | 
| Sets the interval, expressed in milliseconds, at which to raise the xtd::timers::timer::elapsed event.   | |
| 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.   | |
| timer & | synchronizing_object (isynchronize_invoke &value) | 
| Sets the object used to marshal event-handler calls that are issued when an interval has elapsed.   | |
| timer & | synchronizing_object (std::nullptr_t value) | 
| Resets the object used to marshal event-handler calls that are issued when an interval has elapsed.   | |
Public Methods | |
| void | close () | 
| Releases the resources used by the xtd::timers::timer.   | |
| void | start () | 
| Starts raising the xtd::timers::timer::elapsed event by setting xtd::timers::timer::enabled to true.   | |
| void | stop () | 
| Stops raising the xtd::timers::timer::elapsed event by setting xtd::timers::timer::enabled to false.   | |
Additional Inherited Members | |
  Public Member Functions inherited from xtd::object | |
| object ()=default | |
| Create a new instance of the ultimate base class object.   | |
| virtual bool | equals (const object &obj) const noexcept | 
| Determines whether the specified object is equal to the current object.   | |
| virtual size_t | get_hash_code () const noexcept | 
| Serves as a hash function for a particular type.   | |
| virtual type_object | get_type () const noexcept | 
| Gets the type of the current instance.   | |
| template<typename object_t > | |
| xtd::uptr< object_t > | memberwise_clone () const | 
| Creates a shallow copy of the current object.   | |
| virtual xtd::string | to_string () const noexcept | 
| Returns a xtd::string that represents the current object.   | |
  Static Public Member Functions inherited from xtd::object | |
| template<typename object_a_t , typename object_b_t > | |
| static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept | 
| Determines whether the specified object instances are considered equal.   | |
| template<typename object_a_t , typename object_b_t > | |
| static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept | 
| Determines whether the specified object instances are the same instance.   | |
| 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. | 
      
  | 
  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.  | 
      
  | 
  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. | 
| void xtd::timers::timer::close | ( | ) | 
Releases the resources used by the xtd::timers::timer.
| 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.
| event<timer, elapsed_event_handler> xtd::timers::timer::elapsed | 
Occurs when the interval elapses.