System
[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00]
1.0.3300.0
1.0.5000.0
2.0.0.0
4.0.0.0
Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details.
System.ComponentModel.Component
System.ComponentModel.ISupportInitialize
System.ComponentModel.DefaultEvent("Elapsed")
System.ComponentModel.DefaultProperty("Interval")
The component is a server-based timer, which allows you to specify a recurring interval at which the event is raised in your application. You can then handle this event to provide regular processing. For example, suppose you have a critical server that must be kept running 24 hours a day, 7 days a week. You could create a service that uses a to periodically check the server and ensure that the system is up and running. If the system is not responding, the service could attempt to restart the server or notify an administrator.
The server-based is designed for use with worker threads in a multithreaded environment. Server timers can move among threads to handle the raised event, resulting in more accuracy than Windows timers in raising the event on time.
The component raises the event, based on the value of the property. You can handle this event to perform the processing you need. For example, suppose that you have an online sales application that continuously posts sales orders to a database. The service that compiles the instructions for shipping operates on a batch of orders rather than processing each order individually. You could use a to start the batch processing every 30 minutes.
When is set to false, the raises the event only once, after the first has elapsed. To keep raising the event on the , set to true.
In the .NET Framework version 2.0 and earlier, the component catches and suppresses all exceptions thrown by event handlers for the event. This behavior is subject to change in future releases of the .NET Framework.
If the property is null, the event is raised on a thread. If processing of the event lasts longer than , the event might be raised again on another thread. In this situation, the event handler should be reentrant.
The event-handling method might run on one thread at the same time that another thread calls the method or sets the property to false. This might result in the event being raised after the timer is stopped. The example code for the method shows one way to avoid this race condition.
Even if is not null, events can occur after the or method has been called or after the property has been set to false, because the signal to raise the event is always queued for execution on a thread pool thread. One way to resolve this race condition is to set a flag that tells the event handler for the event to ignore subsequent events.
If you use the with a user interface element, such as a form or control, without placing the timer on that user interface element, assign the form or control that contains the to the property, so that the event is marshaled to the user interface thread.
The is not visible at run time.
For a list of initial property values for an instance of , see the constructor.
Generates recurring events in an application.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
The following table shows initial property values for an instance of .
-
Property
Initial value
-
true
-
false
-
100 milliseconds
-
A null reference (Nothing in Visual Basic).
Initializes a new instance of the class, and sets all the properties to their initial values.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
This constructor sets the property of the new timer instance, but does not enable the timer.
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 .
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.ComponentModel.Category("Behavior")
System.ComponentModel.DefaultValue(true)
System.Timers.TimersDescription("Indicates whether the timer will be restarted when it is enabled.")
System.Boolean
true if the timer will raise the Elapsed event multiple times when Interval passes, false if it will raise it just once.
If the is already enabled when the method is called, the interval is reset. If is false, the method must be called in order to start the count again.
Resetting the interval affects when the event is raised. For example, if you set the interval to 5 seconds and then set the property to true, the count starts at the time is set. If you reset the interval to 10 seconds when the count is 3 seconds, the event is raised for the first time 13 seconds after the property was set to true.
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.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
The vsprvslong design environment uses this method to start the initialization of a component that is used on a form or by another component. The method ends the initialization. Using the and methods prevents the control from being used before it is fully initialized.
Begins the run-time initialization of a that is used on a form or by another component.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
This has the same effect as calling , or setting to false.
Releases the resources used by the .
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
Disables and disposes of the timer component.
Releases all resources used by the current .
true to release both managed and unmanaged resources; false to release only unmanaged resources.
Event
1.0.5000.0
2.0.0.0
4.0.0.0
System.ComponentModel.Category("Behavior")
System.Timers.TimersDescription("Occurs when the Interval has elapsed.")
System.Timers.ElapsedEventHandler
If is set to true and is set to false, the raises the event only once, the first time the interval elapses.
If is set after the has started, the count is reset. For example, if you set the interval to 5 seconds and then set to true, the count starts at the time is set. If you reset the interval to 10 seconds when count is 3 seconds, the event is raised for the first time 13 seconds after was set to true.
If the property is null, the event is raised on a thread. If the processing of the event lasts longer than , the event might be raised again on another thread. In this situation, the event handler should be reentrant.
The event-handling method might run on one thread at the same time that another thread calls the method or sets the property to false. This might result in the event being raised after the timer is stopped. The example code for the method shows one way to avoid this race condition.
Even if is not null, events can occur after the or method has been called or after the property has been set to false, because the signal to raise the event is always queued for execution on a thread pool thread. One way to resolve this race condition is to set a flag that tells the event handler for the event to ignore subsequent events.
The component catches and suppresses all exceptions thrown by event handlers for the event. This behavior is subject to change in future releases of the .NET Framework.
Occurs when the interval elapses.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.ComponentModel.Category("Behavior")
System.ComponentModel.DefaultValue(false)
System.Timers.TimersDescription("Indicates whether the timer is enabled to fire events at a defined interval.")
System.Boolean
Boolean true if this timer is enabled, or boolean false if this timer is disabled.
Setting to true is the same as calling , while setting to false is the same as calling .
The signal to raise the event is always queued for execution on a thread. This might result in the event being raised after the property is set to false. The code example for the method shows one way to work around this race condition.
If is set to true and is set to false, the raises the event only once, the first time the interval elapses.
If the interval is set after the has started, the count is reset. For example, if you set the interval to 5 seconds and then set the property to true, the count starts at the time is set. If you reset the interval to 10 seconds when count is 3 seconds, the event is raised for the first time 13 seconds after was set to true.
Some visual designers, such as those in Microsoft Visual Studio, set the property to true when inserting a new .
Gets or sets a value indicating whether the should raise the event.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
The vsprvslong design environment uses this method to end the initialization of a component that is used on a form or by another component. The method starts the initialization. Using the and methods prevents the control from being used before it is fully initialized.
Ends the run-time initialization of a that is used on a form or by another component.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.ComponentModel.Category("Behavior")
System.ComponentModel.DefaultValue(100)
System.ComponentModel.RecommendedAsConfigurable(true)
System.Timers.TimersDescription("The number of milliseconds between timer events.")
System.Double
Double value representing the number of milliseconds for the interval.
If the interval is set after the has started, the count is reset. For example, if you set the interval to 5 seconds and then set the property to true, the count starts at the time is set. If you reset the interval to 10 seconds when count is 3 seconds, the event is raised for the first time 13 seconds after was set to true.
If is set to true and is set to false, the raises the event only once, the first time the interval elapses. is then set to false.
If and are both set to false, and the timer has previously been enabled, setting the property causes the event to be raised once, as if the property had been set to true. To set the interval without raising the event, you can temporarily set the property to true.
Gets or sets the interval at which to raise the event.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.ComponentModel.ISite
To be added: an object of type 'ComponentModel.ISite'
Sites bind a to a and enable communication between them, as well as providing a way for the container to manage its components.
Gets or sets the site that binds the to its container in design mode.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
If is set to true and is set to false, the raises the event only once, the first time the interval elapses. When is true and is true, the continues to raise the event on the specified interval.
You can also start timing by setting to true.
If is false, the method must be called in order to start the count again.
Starts raising the event by setting to true.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
You can also stop timing by setting to false.
The signal to raise the event is always queued for execution on a thread, so the event-handling method might run on one thread at the same time that a call to the method runs on another thread. This might result in the event being raised after the method is called. The code example in the next section shows one way to work around this race condition.
Stops raising the event by setting to false.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.ComponentModel.Browsable(false)
System.ComponentModel.DefaultValue(null)
System.Timers.TimersDescription("The object used to marshal the event handler calls issued when an interval has elapsed.")
System.ComponentModel.ISynchronizeInvoke
To be added: an object of type 'ComponentModel.ISynchronizeInvoke'
When is null, the method that handles the event is called on a thread from the system-thread pool. For more information on system-thread pools, see .
When the event is handled by a visual Windows Forms component, such as a button, accessing the component through the system-thread pool might result in an exception or just might not work. Avoid this effect by setting to a Windows Forms component, which causes the method that handles the event to be called on the same thread that the component was created on.
Even if the property is not null, events can occur after the or method has been called or after the property has been set to false, because the signal to raise the event is always queued for execution on a thread pool thread. One way to resolve this race condition is to set a flag that tells the event handler for the event to ignore subsequent events.
If the is used inside Visual Studio in a Windows Forms designer, is automatically set to the control that contains the . For example, if you place a on a designer for Form1 (which inherits from ), the property of is set to the instance of Form1.
Gets or sets the object used to marshal event-handler calls that are issued when an interval has elapsed.