mscorlib(4.0.0.0) API with additions
System.Timers.Timer Class Reference

Generates an event after a set interval, with an option to generate recurring events.To browse the .NET Framework source code for this type, see the Reference Source. More...

Inheritance diagram for System.Timers.Timer:
[legend]
Collaboration diagram for System.Timers.Timer:
[legend]

Public Member Functions

 Timer ()
 Initializes a new instance of the T:System.Timers.Timer class, and sets all the properties to their initial values. More...
 
 Timer (double interval)
 Initializes a new instance of the T:System.Timers.Timer class, and sets the P:System.Timers.Timer.Interval property to the specified number of milliseconds. More...
 
void BeginInit ()
 Begins the run-time initialization of a T:System.Timers.Timer that is used on a form or by another component. More...
 
void Close ()
 Releases the resources used by the T:System.Timers.Timer. More...
 
void EndInit ()
 Ends the run-time initialization of a T:System.Timers.Timer that is used on a form or by another component. More...
 
void Start ()
 Starts raising the E:System.Timers.Timer.Elapsed event by setting P:System.Timers.Timer.Enabled to true. More...
 
void Stop ()
 Stops raising the E:System.Timers.Timer.Elapsed event by setting P:System.Timers.Timer.Enabled to false. More...
 
- Public Member Functions inherited from System.ComponentModel.Component
void Dispose ()
 Releases all resources used by the T:System.ComponentModel.Component. More...
 
override string ToString ()
 Returns a T:System.String containing the name of the T:System.ComponentModel.Component, if any. This method should not be overridden. More...
 
- Public Member Functions inherited from System.MarshalByRefObject
object GetLifetimeService ()
 Retrieves the current lifetime service object that controls the lifetime policy for this instance. More...
 
virtual object InitializeLifetimeService ()
 Obtains a lifetime service object to control the lifetime policy for this instance. More...
 
virtual ObjRef CreateObjRef (Type requestedType)
 Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. More...
 

Protected Member Functions

override void Dispose (bool disposing)
 Releases all resources used by the current T:System.Timers.Timer. More...
 
- Protected Member Functions inherited from System.ComponentModel.Component
virtual object GetService (Type service)
 Returns an object that represents a service provided by the T:System.ComponentModel.Component or by its T:System.ComponentModel.Container. More...
 
- Protected Member Functions inherited from System.MarshalByRefObject
MarshalByRefObject MemberwiseClone (bool cloneIdentity)
 Creates a shallow copy of the current T:System.MarshalByRefObject object. More...
 

Properties

bool AutoReset [get, set]
 Gets or sets a Boolean indicating whether the T:System.Timers.Timer should raise the E:System.Timers.Timer.Elapsed event only once (false) or repeatedly (true). More...
 
bool? Enabled [get, set]
 Gets or sets a value indicating whether the T:System.Timers.Timer should raise the E:System.Timers.Timer.Elapsed event. More...
 
double Interval [get, set]
 Gets or sets the interval, expressed in milliseconds, at which to raise the E:System.Timers.Timer.Elapsed event. More...
 
override ISite Site [get, set]
 Gets or sets the site that binds the T:System.Timers.Timer to its container in design mode. More...
 
ISynchronizeInvoke SynchronizingObject [get, set]
 Gets or sets the object used to marshal event-handler calls that are issued when an interval has elapsed. More...
 
ElapsedEventHandler Elapsed
 Occurs when the interval elapses. More...
 
- Properties inherited from System.ComponentModel.Component
EventHandlerList Events [get]
 Gets the list of event handlers that are attached to this T:System.ComponentModel.Component. More...
 
virtual ISite Site [get, set]
 Gets or sets the T:System.ComponentModel.ISite of the T:System.ComponentModel.Component. More...
 
IContainerContainer [get]
 Gets the T:System.ComponentModel.IContainer that contains the T:System.ComponentModel.Component. More...
 
bool??? DesignMode [get]
 Gets a value that indicates whether the T:System.ComponentModel.Component is currently in design mode. More...
 
EventHandler Disposed
 Occurs when the component is disposed by a call to the M:System.ComponentModel.Component.Dispose method. More...
 
- Properties inherited from System.ComponentModel.IComponent
ISite Site [get, set]
 Gets or sets the T:System.ComponentModel.ISite associated with the T:System.ComponentModel.IComponent. More...
 

Additional Inherited Members

- Protected Attributes inherited from System.ComponentModel.Component
virtual bool CanRaiseEvents => true
 Gets a value indicating whether the component can raise an event. More...
 
- Events inherited from System.ComponentModel.IComponent
EventHandler Disposed
 Represents the method that handles the E:System.ComponentModel.IComponent.Disposed event of a component. More...
 

Detailed Description

Generates an event after a set interval, with an option to generate recurring events.To browse the .NET Framework source code for this type, see the Reference Source.

Definition at line 14 of file Timer.cs.

Constructor & Destructor Documentation

◆ Timer() [1/2]

System.Timers.Timer.Timer ( )

Initializes a new instance of the T:System.Timers.Timer class, and sets all the properties to their initial values.

Definition at line 225 of file Timer.cs.

◆ Timer() [2/2]

System.Timers.Timer.Timer ( double  interval)

Initializes a new instance of the T:System.Timers.Timer class, and sets the P:System.Timers.Timer.Interval property to the specified number of milliseconds.

Parameters
intervalThe time, in milliseconds, between events. The value must be greater than zero and less than or equal to F:System.Int32.MaxValue.
Exceptions
T:System.ArgumentExceptionThe value of the interval parameter is less than or equal to zero, or greater than F:System.Int32.MaxValue.

Definition at line 238 of file Timer.cs.

Member Function Documentation

◆ BeginInit()

void System.Timers.Timer.BeginInit ( )

Begins the run-time initialization of a T:System.Timers.Timer that is used on a form or by another component.

Implements System.ComponentModel.ISupportInitialize.

Definition at line 260 of file Timer.cs.

◆ Close()

void System.Timers.Timer.Close ( )

Releases the resources used by the T:System.Timers.Timer.

Definition at line 267 of file Timer.cs.

◆ Dispose()

override void System.Timers.Timer.Dispose ( bool  disposing)
protectedvirtual

Releases all resources used by the current T:System.Timers.Timer.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

Reimplemented from System.ComponentModel.Component.

Definition at line 282 of file Timer.cs.

◆ EndInit()

void System.Timers.Timer.EndInit ( )

Ends the run-time initialization of a T:System.Timers.Timer that is used on a form or by another component.

Implements System.ComponentModel.ISupportInitialize.

Definition at line 290 of file Timer.cs.

◆ Start()

void System.Timers.Timer.Start ( )

Starts raising the E:System.Timers.Timer.Elapsed event by setting P:System.Timers.Timer.Enabled to true.

Exceptions
T:System.ArgumentOutOfRangeExceptionThe T:System.Timers.Timer is created with an interval equal to or greater than F:System.Int32.MaxValue + 1, or set to an interval less than zero.

Definition at line 298 of file Timer.cs.

◆ Stop()

void System.Timers.Timer.Stop ( )

Stops raising the E:System.Timers.Timer.Elapsed event by setting P:System.Timers.Timer.Enabled to false.

Definition at line 304 of file Timer.cs.

Property Documentation

◆ AutoReset

bool System.Timers.Timer.AutoReset
getset

Gets or sets a Boolean indicating whether the T:System.Timers.Timer should raise the E:System.Timers.Timer.Elapsed event only once (false) or repeatedly (true).

Returns
true if the T:System.Timers.Timer should raise the E:System.Timers.Timer.Elapsed event each time the interval elapses; false if it should raise the E:System.Timers.Timer.Elapsed event only once, after the first time the interval elapses. The default is true.

Definition at line 52 of file Timer.cs.

◆ Elapsed

ElapsedEventHandler System.Timers.Timer.Elapsed
addremove

Occurs when the interval elapses.

Definition at line 213 of file Timer.cs.

◆ Enabled

bool? System.Timers.Timer.Enabled
getset

Gets or sets a value indicating whether the T:System.Timers.Timer should raise the E:System.Timers.Timer.Elapsed event.

Returns
true if the T:System.Timers.Timer should raise the E:System.Timers.Timer.Elapsed event; otherwise, false. The default is false.
Exceptions
T:System.ObjectDisposedExceptionThis property cannot be set because the timer has been disposed.
T:System.ArgumentExceptionThe P:System.Timers.Timer.Interval property was set to a value greater than F:System.Int32.MaxValue before the timer was enabled.

Definition at line 83 of file Timer.cs.

◆ Interval

double System.Timers.Timer.Interval
getset

Gets or sets the interval, expressed in milliseconds, at which to raise the E:System.Timers.Timer.Elapsed event.

Returns
The time, in milliseconds, between E:System.Timers.Timer.Elapsed events. The value must be greater than zero, and less than or equal to F:System.Int32.MaxValue. The default is 100 milliseconds.
Exceptions
T:System.ArgumentExceptionThe interval is less than or equal to zero.-or-The interval is greater than F:System.Int32.MaxValue, and the timer is currently enabled. (If the timer is not currently enabled, no exception is thrown until it becomes enabled.)

Definition at line 143 of file Timer.cs.

◆ Site

override ISite System.Timers.Timer.Site
getset

Gets or sets the site that binds the T:System.Timers.Timer to its container in design mode.

Returns
An T:System.ComponentModel.ISite interface representing the site that binds the T:System.Timers.Timer object to its container.

Definition at line 165 of file Timer.cs.

◆ SynchronizingObject

ISynchronizeInvoke System.Timers.Timer.SynchronizingObject
getset

Gets or sets the object used to marshal event-handler calls that are issued when an interval has elapsed.

Returns
The T:System.ComponentModel.ISynchronizeInvoke representing the object used to marshal the event-handler calls that are issued when an interval has elapsed. The default is null.

Definition at line 186 of file Timer.cs.


The documentation for this class was generated from the following file: