|
|
|
@@ -0,0 +1,278 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
namespace System.Timers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Generates recurring events in an application.</summary>
|
|
|
|
|
// 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
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Timers.Timer" /> class, and sets all the properties to their initial values.</summary>
|
|
|
|
|
// Token: 0x06001B37 RID: 6967 RVA: 0x00063DF4 File Offset: 0x00061FF4
|
|
|
|
|
public Timer()
|
|
|
|
|
: this(100.0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Timers.Timer" /> class, and sets the <see cref="P:System.Timers.Timer.Interval" /> property to the specified number of milliseconds.</summary>
|
|
|
|
|
/// <param name="interval">The time, in milliseconds, between events. The value must be greater than zero and less than or equal to <see cref="F:System.Int32.MaxValue" />.</param>
|
|
|
|
|
/// <exception cref="T:System.ArgumentException">The value of the <paramref name="interval" /> parameter is less than or equal to zero, or greater than <see cref="F:System.Int32.MaxValue" />. </exception>
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Occurs when the interval elapses.</summary>
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
|
|
/// <summary>Gets or sets a value indicating whether the <see cref="T:System.Timers.Timer" /> should raise the <see cref="E:System.Timers.Timer.Elapsed" /> event each time the specified interval elapses or only after the first time it elapses.</summary>
|
|
|
|
|
/// <returns>true if the <see cref="T:System.Timers.Timer" /> should raise the <see cref="E:System.Timers.Timer.Elapsed" /> event each time the interval elapses; false if it should raise the <see cref="E:System.Timers.Timer.Elapsed" /> event only once, after the first time the interval elapses. The default is true.</returns>
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Gets or sets a value indicating whether the <see cref="T:System.Timers.Timer" /> should raise the <see cref="E:System.Timers.Timer.Elapsed" /> event.</summary>
|
|
|
|
|
/// <returns>true if the <see cref="T:System.Timers.Timer" /> should raise the <see cref="E:System.Timers.Timer.Elapsed" /> event; otherwise, false. The default is false.</returns>
|
|
|
|
|
/// <exception cref="T:System.ObjectDisposedException">This property cannot be set because the timer has been disposed.</exception>
|
|
|
|
|
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Timers.Timer.Interval" /> property was set to a value greater than <see cref="F:System.Int32.MaxValue" /> before the timer was enabled. </exception>
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Gets or sets the interval at which to raise the <see cref="E:System.Timers.Timer.Elapsed" /> event.</summary>
|
|
|
|
|
/// <returns>The time, in milliseconds, between <see cref="E:System.Timers.Timer.Elapsed" /> events. The value must be greater than zero, and less than or equal to <see cref="F:System.Int32.MaxValue" />. The default is 100 milliseconds.</returns>
|
|
|
|
|
/// <exception cref="T:System.ArgumentException">The interval is less than or equal to zero.-or-The interval is greater than <see cref="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.) </exception>
|
|
|
|
|
// 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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Gets or sets the site that binds the <see cref="T:System.Timers.Timer" /> to its container in design mode.</summary>
|
|
|
|
|
/// <returns>An <see cref="T:System.ComponentModel.ISite" /> interface representing the site that binds the <see cref="T:System.Timers.Timer" /> object to its container.</returns>
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Gets or sets the object used to marshal event-handler calls that are issued when an interval has elapsed.</summary>
|
|
|
|
|
/// <returns>The <see cref="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.</returns>
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Begins the run-time initialization of a <see cref="T:System.Timers.Timer" /> that is used on a form or by another component.</summary>
|
|
|
|
|
// Token: 0x06001B45 RID: 6981 RVA: 0x00064088 File Offset: 0x00062288
|
|
|
|
|
public void BeginInit()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Releases the resources used by the <see cref="T:System.Timers.Timer" />.</summary>
|
|
|
|
|
// Token: 0x06001B46 RID: 6982 RVA: 0x0006408C File Offset: 0x0006228C
|
|
|
|
|
public void Close()
|
|
|
|
|
{
|
|
|
|
|
this.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Ends the run-time initialization of a <see cref="T:System.Timers.Timer" /> that is used on a form or by another component.</summary>
|
|
|
|
|
/// <PermissionSet>
|
|
|
|
|
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
|
|
|
|
|
/// </PermissionSet>
|
|
|
|
|
// Token: 0x06001B47 RID: 6983 RVA: 0x00064098 File Offset: 0x00062298
|
|
|
|
|
public void EndInit()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Starts raising the <see cref="E:System.Timers.Timer.Elapsed" /> event by setting <see cref="P:System.Timers.Timer.Enabled" /> to true.</summary>
|
|
|
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">The <see cref="T:System.Timers.Timer" /> is created with an interval equal to or greater than <see cref="F:System.Int32.MaxValue" /> + 1, or set to an interval less than zero.</exception>
|
|
|
|
|
/// <PermissionSet>
|
|
|
|
|
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
|
|
|
|
|
/// </PermissionSet>
|
|
|
|
|
// Token: 0x06001B48 RID: 6984 RVA: 0x0006409C File Offset: 0x0006229C
|
|
|
|
|
public void Start()
|
|
|
|
|
{
|
|
|
|
|
this.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Stops raising the <see cref="E:System.Timers.Timer.Elapsed" /> event by setting <see cref="P:System.Timers.Timer.Enabled" /> to false.</summary>
|
|
|
|
|
/// <PermissionSet>
|
|
|
|
|
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
|
|
|
|
|
/// </PermissionSet>
|
|
|
|
|
// Token: 0x06001B49 RID: 6985 RVA: 0x000640A8 File Offset: 0x000622A8
|
|
|
|
|
public void Stop()
|
|
|
|
|
{
|
|
|
|
|
this.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Releases all resources used by the current <see cref="T:System.Timers.Timer" />.</summary>
|
|
|
|
|
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources. </param>
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
}
|