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...
|
| 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...
|
|
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...
|
|
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...
|
|
|
override void | Dispose (bool disposing) |
| Releases all resources used by the current T:System.Timers.Timer. More...
|
|
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...
|
|
MarshalByRefObject | MemberwiseClone (bool cloneIdentity) |
| Creates a shallow copy of the current T:System.MarshalByRefObject object. More...
|
|
|
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...
|
|
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...
|
|
IContainer? | Container [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...
|
|
ISite | Site [get, set] |
| Gets or sets the T:System.ComponentModel.ISite associated with the T:System.ComponentModel.IComponent. More...
|
|
|
virtual bool | CanRaiseEvents => true |
| Gets a value indicating whether the component can raise an event. More...
|
|
EventHandler | Disposed |
| Represents the method that handles the E:System.ComponentModel.IComponent.Disposed event of a component. More...
|
|
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.
◆ 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
-
interval | The 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.ArgumentException | The 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.
◆ BeginInit()
void System.Timers.Timer.BeginInit |
( |
| ) |
|
◆ 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
-
disposing | true 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 |
( |
| ) |
|
◆ 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.ArgumentOutOfRangeException | The 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.
◆ 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
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.ObjectDisposedException | This property cannot be set because the timer has been disposed. |
T:System.ArgumentException | The 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.ArgumentException | The 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
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: