Saturday, August 31, 2013

C# - Question about events (also textbox clearing and starting/stopping a timer)

Hi all,


I basically have a System.Timers.Timer that is set to trigger an event every 10 seconds. In the event, I used textbox.Clear(); so that every time the event is triggered, the textbox clears. Unfortunately, this does not work. I also tried textbox.Text = ""; but it still does not work. The textbox is not clearing. Any idea why this happens?


In the beginning of the event, I also wrote this line: myTimer.Enabled = false; to temporarily stop the timer when the event starts. I also wrote this line: myTimer.Enabled = true; just before the event ends to start the timer again. Basically I don't want it to start/trigger the event again while the event is not yet finished executing. Is it okay to do this? or is there a better way to do this?


Please let me know. Thanks





No comments:

Post a Comment