using System; using System.ComponentModel; using System.Threading; namespace System.Timers { /// Generates recurring events in an application. // Token: 0x020002EF RID: 751 [global::System.ComponentModel.DefaultEvent("Elapsed")] [global::System.ComponentModel.DefaultProperty("Interval")] public class Timer : global::System.ComponentModel.Component, global::System.ComponentModel.ISupportInitialize { /// Initializes a new instance of the class, and sets all the properties to their initial values. // Token: 0x06001B37 RID: 6967 RVA: 0x00063DF4 File Offset: 0x00061FF4 public Timer() : this(100.0) { } /// Initializes a new instance of the class, and sets the property to the specified number of milliseconds. /// The time, in milliseconds, between events. The value must be greater than zero and less than or equal to . /// The value of the parameter is less than or equal to zero, or greater than . // Token: 0x06001B38 RID: 6968 RVA: 0x00063E08 File Offset: 0x00062008 public Timer(double interval) { if (interval > 2147483647.0) { throw new ArgumentException("Invalid value: " + interval, "interval"); } this.autoReset = true; this.Interval = interval; } /// Occurs when the interval elapses. // Token: 0x14000032 RID: 50 // (add) Token: 0x06001B39 RID: 6969 RVA: 0x00063E60 File Offset: 0x00062060 // (remove) Token: 0x06001B3A RID: 6970 RVA: 0x00063E7C File Offset: 0x0006207C [TimersDescription("Occurs when the Interval has elapsed.")] [global::System.ComponentModel.Category("Behavior")] public event ElapsedEventHandler Elapsed; /// Gets or sets a value indicating whether the should raise the event each time the specified interval elapses or only after the first time it elapses. /// true if the should raise the event each time the interval elapses; false if it should raise the event only once, after the first time the interval elapses. The default is true. // Token: 0x1700084C RID: 2124 // (get) Token: 0x06001B3B RID: 6971 RVA: 0x00063E98 File Offset: 0x00062098 // (set) Token: 0x06001B3C RID: 6972 RVA: 0x00063EA0 File Offset: 0x000620A0 [global::System.ComponentModel.Category("Behavior")] [global::System.ComponentModel.DefaultValue(true)] [TimersDescription("Indicates whether the timer will be restarted when it is enabled.")] public bool AutoReset { get { return this.autoReset; } set { this.autoReset = value; } } /// Gets or sets a value indicating whether the should raise the event. /// true if the should raise the event; otherwise, false. The default is false. /// This property cannot be set because the timer has been disposed. /// The property was set to a value greater than before the timer was enabled. // Token: 0x1700084D RID: 2125 // (get) Token: 0x06001B3D RID: 6973 RVA: 0x00063EAC File Offset: 0x000620AC // (set) Token: 0x06001B3E RID: 6974 RVA: 0x00063F04 File Offset: 0x00062104 [global::System.ComponentModel.Category("Behavior")] [TimersDescription("Indicates whether the timer is enabled to fire events at a defined interval.")] [global::System.ComponentModel.DefaultValue(false)] public bool Enabled { get { object @lock = this._lock; bool flag; lock (@lock) { flag = this.timer != null; } return flag; } set { object @lock = this._lock; lock (@lock) { bool flag = this.timer != null; if (flag != value) { if (value) { this.timer = new Timer(new TimerCallback(Timer.Callback), this, (int)this.interval, (!this.autoReset) ? 0 : ((int)this.interval)); } else { this.timer.Dispose(); this.timer = null; } } } } } /// Gets or sets the interval at which to raise the event. /// The time, in milliseconds, between events. The value must be greater than zero, and less than or equal to . The default is 100 milliseconds. /// The interval is less than or equal to zero.-or-The interval is greater than , and the timer is currently enabled. (If the timer is not currently enabled, no exception is thrown until it becomes enabled.) // Token: 0x1700084E RID: 2126 // (get) Token: 0x06001B3F RID: 6975 RVA: 0x00063FB4 File Offset: 0x000621B4 // (set) Token: 0x06001B40 RID: 6976 RVA: 0x00063FBC File Offset: 0x000621BC [global::System.ComponentModel.DefaultValue(100)] [global::System.ComponentModel.Category("Behavior")] [global::System.ComponentModel.RecommendedAsConfigurable(true)] [TimersDescription("The number of milliseconds between timer events.")] public double Interval { get { return this.interval; } set { if (value <= 0.0) { throw new ArgumentException("Invalid value: " + value); } object @lock = this._lock; lock (@lock) { this.interval = value; if (this.timer != null) { this.timer.Change((int)this.interval, (!this.autoReset) ? 0 : ((int)this.interval)); } } } } /// Gets or sets the site that binds the to its container in design mode. /// An interface representing the site that binds the object to its container. // Token: 0x1700084F RID: 2127 // (get) Token: 0x06001B41 RID: 6977 RVA: 0x00064060 File Offset: 0x00062260 // (set) Token: 0x06001B42 RID: 6978 RVA: 0x00064068 File Offset: 0x00062268 public override global::System.ComponentModel.ISite Site { get { return base.Site; } set { base.Site = value; } } /// Gets or sets the object used to marshal event-handler calls that are issued when an interval has elapsed. /// The representing the object used to marshal the event-handler calls that are issued when an interval has elapsed. The default is null. // Token: 0x17000850 RID: 2128 // (get) Token: 0x06001B43 RID: 6979 RVA: 0x00064074 File Offset: 0x00062274 // (set) Token: 0x06001B44 RID: 6980 RVA: 0x0006407C File Offset: 0x0006227C [global::System.ComponentModel.DefaultValue(null)] [global::System.ComponentModel.Browsable(false)] [TimersDescription("The object used to marshal the event handler calls issued when an interval has elapsed.")] public global::System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get { return this.so; } set { this.so = value; } } /// Begins the run-time initialization of a that is used on a form or by another component. // Token: 0x06001B45 RID: 6981 RVA: 0x00064088 File Offset: 0x00062288 public void BeginInit() { } /// Releases the resources used by the . // Token: 0x06001B46 RID: 6982 RVA: 0x0006408C File Offset: 0x0006228C public void Close() { this.Enabled = false; } /// Ends the run-time initialization of a that is used on a form or by another component. /// /// /// // Token: 0x06001B47 RID: 6983 RVA: 0x00064098 File Offset: 0x00062298 public void EndInit() { } /// Starts raising the event by setting to true. /// The is created with an interval equal to or greater than + 1, or set to an interval less than zero. /// /// /// // Token: 0x06001B48 RID: 6984 RVA: 0x0006409C File Offset: 0x0006229C public void Start() { this.Enabled = true; } /// Stops raising the event by setting to false. /// /// /// // Token: 0x06001B49 RID: 6985 RVA: 0x000640A8 File Offset: 0x000622A8 public void Stop() { this.Enabled = false; } /// Releases all resources used by the current . /// true to release both managed and unmanaged resources; false to release only unmanaged resources. // Token: 0x06001B4A RID: 6986 RVA: 0x000640B4 File Offset: 0x000622B4 protected override void Dispose(bool disposing) { this.Close(); base.Dispose(disposing); } // Token: 0x06001B4B RID: 6987 RVA: 0x000640C4 File Offset: 0x000622C4 private static void Callback(object state) { Timer timer = (Timer)state; if (!timer.Enabled) { return; } ElapsedEventHandler elapsed = timer.Elapsed; if (!timer.autoReset) { timer.Enabled = false; } if (elapsed == null) { return; } ElapsedEventArgs elapsedEventArgs = new ElapsedEventArgs(DateTime.Now); if (timer.so != null && timer.so.InvokeRequired) { timer.so.BeginInvoke(elapsed, new object[] { timer, elapsedEventArgs }); } else { try { elapsed(timer, elapsedEventArgs); } catch { } } } // Token: 0x040015D3 RID: 5587 private double interval; // Token: 0x040015D4 RID: 5588 private bool autoReset; // Token: 0x040015D5 RID: 5589 private Timer timer; // Token: 0x040015D6 RID: 5590 private object _lock = new object(); // Token: 0x040015D7 RID: 5591 private global::System.ComponentModel.ISynchronizeInvoke so; } }