Reputation: 1353
I am building a custom control for a few of my forms which is an "indictor light"; an edit control that just changed color.
I would like to set a timer and see what the "light" looks like when it switches from state to state.
I have been reviewing this link C# Elapsed Timer MSDN
Though this does not work for me. I think the issue has to do with the Timer
executing on another Thread meaning I cannot interact with the this
(this.editControl.[...]) within the OnTimedEvent
method.
Is there a simple Timer I could use to just call a method of a forms controls every second or so?
Upvotes: 0
Views: 87
Reputation: 65079
Use the Timer control (the System.Windows.Forms.Timer
class). You can find it in the Toolbox when on a designer canvas.
Set the Interval
property to 1000 (1 second) and make sure its Enabled
. The Tick
event fires at every interval and is raised in the UI thread.
Upvotes: 1