11 [DefaultProperty(
"Interval")]
12 [DefaultEvent(
"Elapsed")]
13 [HostProtection(
SecurityAction.LinkDemand, Synchronization =
true, ExternalThreading =
true)]
16 internal struct FILE_TIME
18 internal int ftTimeLow;
20 internal int ftTimeHigh;
23 private double interval;
27 private bool initializing;
29 private bool delayedEnable;
33 private bool autoReset;
37 private bool disposed;
43 private object cookie;
48 [Category(
"Behavior")]
49 [TimersDescription(
"TimerAutoReset")]
63 else if (autoReset != value)
79 [Category(
"Behavior")]
80 [TimersDescription(
"TimerEnabled")]
92 delayedEnable = value;
95 else if (initializing)
97 delayedEnable = value;
101 if (enabled == value)
124 cookie =
new object();
138 [Category(
"Behavior")]
139 [TimersDescription(
"TimerInterval")]
140 [DefaultValue(100.0)]
141 [SettingsBindable(
true)]
184 [TimersDescription(
"TimerSynchronizingObject")]
189 if (synchronizingObject ==
null && base.DesignMode)
192 if (designerHost !=
null)
201 return synchronizingObject;
205 synchronizingObject = value;
210 [Category(
"Behavior")]
211 [TimersDescription(
"TimerIntervalElapsed")]
230 initializing =
false;
231 delayedEnable =
false;
232 callback = MyTimerCallback;
243 throw new ArgumentException(SR.GetString(
"InvalidParameter",
"interval", interval));
246 if (num > 2147483647.0 || num <= 0.0)
248 throw new ArgumentException(SR.GetString(
"InvalidParameter",
"interval", interval));
250 this.interval = (int)num;
253 private void UpdateTimer()
256 timer.Change(num, autoReset ? num : (-1));
269 initializing =
false;
270 delayedEnable =
false;
282 protected override void Dispose(
bool disposing)
286 base.Dispose(disposing);
292 initializing =
false;
309 private void MyTimerCallback(
object state)
317 FILE_TIME lpSystemTimeAsFileTime =
default(FILE_TIME);
318 GetSystemTimeAsFileTime(ref lpSystemTimeAsFileTime);
319 ElapsedEventArgs elapsedEventArgs =
new ElapsedEventArgs(lpSystemTimeAsFileTime.ftTimeLow, lpSystemTimeAsFileTime.ftTimeHigh);
323 if (elapsedEventHandler !=
null)
335 elapsedEventHandler(
this, elapsedEventArgs);
345 [DllImport(
"kernel32.dll")]
346 [SuppressUnmanagedCodeSecurity]
347 internal static extern void GetSystemTimeAsFileTime(ref FILE_TIME lpSystemTimeAsFileTime);
void Stop()
Stops raising the E:System.Timers.Timer.Elapsed event by setting P:System.Timers.Timer....
override ISite Site
Gets or sets the site that binds the T:System.Timers.Timer to its container in design mode.
IComponent RootComponent
Gets the instance of the base class used as the root component for the current design.
Provides a way to synchronously or asynchronously execute a delegate.
void Close()
Releases the resources used by the T:System.Timers.Timer.
ElapsedEventHandler Elapsed
Occurs when the interval elapses.
static Delegate Remove(Delegate source, Delegate value)
Removes the last occurrence of the invocation list of a delegate from the invocation list of another ...
static Delegate Combine(Delegate a, Delegate b)
Concatenates the invocation lists of two delegates.
double Interval
Gets or sets the interval, expressed in milliseconds, at which to raise the E:System....
bool InvokeRequired
Gets a value indicating whether the caller must call M:System.ComponentModel.ISynchronizeInvoke....
Timer()
Initializes a new instance of the T:System.Timers.Timer class, and sets all the properties to their i...
The exception that is thrown when an operation is performed on a disposed object.
SecurityAction
Specifies the security actions that can be performed using declarative security.
void BeginInit()
Begins the run-time initialization of a T:System.Timers.Timer that is used on a form or by another co...
delegate void TimerCallback(object state)
Represents the method that handles calls from a T:System.Threading.Timer.
Provides a mechanism for executing a method on a thread pool thread at specified intervals....
Provides the base implementation for the T:System.ComponentModel.IComponent interface and enables obj...
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
Generates an event after a set interval, with an option to generate recurring events....
override void Dispose(bool disposing)
Releases all resources used by the current T:System.Timers.Timer.
virtual object GetService(Type service)
Returns an object that represents a service provided by the T:System.ComponentModel....
void Start()
Starts raising the E:System.Timers.Timer.Elapsed event by setting P:System.Timers....
The exception that is thrown when one of the arguments provided to a method is not valid.
delegate void ElapsedEventHandler(object sender, ElapsedEventArgs e)
Represents the method that will handle the E:System.Timers.Timer.Elapsed event of a T:System....
void EndInit()
Ends the run-time initialization of a T:System.Timers.Timer that is used on a form or by another comp...
Provides an interface for managing designer transactions and components.
bool? Enabled
Gets or sets a value indicating whether the T:System.Timers.Timer should raise the E:System....
bool AutoReset
Gets or sets a Boolean indicating whether the T:System.Timers.Timer should raise the E:System....
IAsyncResult BeginInvoke(Delegate method, object[] args)
Asynchronously executes the delegate on the thread that created this object.
Timer(double interval)
Initializes a new instance of the T:System.Timers.Timer class, and sets the P:System....
Provides constants and static methods for trigonometric, logarithmic, and other common mathematical f...
Provides functionality required by sites.
Specifies that this object supports a simple, transacted notification for batch initialization.
static decimal Ceiling(decimal d)
Returns the smallest integral value that is greater than or equal to the specified decimal number.
ISynchronizeInvoke SynchronizingObject
Gets or sets the object used to marshal event-handler calls that are issued when an interval has elap...