Problem with timer event fireing
-
I have a socket app. I have an event that is fired when the connection is closed. This event is caught stops my other two timers, and enables a 3rd timer, sets the timer interval and starts it. But it never happens, it never drops in to the tick event method. I have two other timers that are started from an event...like when the connection is up, they work fine. But it does not work when the connection is closed. Not sure what code to post to help out as the event is in once class, the socket in another class, etc. Why would a timer not fire on the tick event? Thanks
Tom Wright tawright915@gmail.com
-
I have a socket app. I have an event that is fired when the connection is closed. This event is caught stops my other two timers, and enables a 3rd timer, sets the timer interval and starts it. But it never happens, it never drops in to the tick event method. I have two other timers that are started from an event...like when the connection is up, they work fine. But it does not work when the connection is closed. Not sure what code to post to help out as the event is in once class, the socket in another class, etc. Why would a timer not fire on the tick event? Thanks
Tom Wright tawright915@gmail.com
you should try to get more information. do you use an ide? if yes, which one and does it support breakpoints?! if so, use them. make sure you see the line, where the timer is started, being executed. also print out the values of the timer before it get started. compare the code of the other two timers and so on. before starting any timer, you should print its values to make sure its set up correctly. try to debug it because, as you already said, noone will know where to start searching.
-
you should try to get more information. do you use an ide? if yes, which one and does it support breakpoints?! if so, use them. make sure you see the line, where the timer is started, being executed. also print out the values of the timer before it get started. compare the code of the other two timers and so on. before starting any timer, you should print its values to make sure its set up correctly. try to debug it because, as you already said, noone will know where to start searching.
yes I'm stepping thru my code (VS2003) and the interval is getting set. The timer is getting started. It's just never fired. The last statement that is stepped thru is: this.autoEvent.Set(); this is in the socket class. It is reseting my events when the socket is closed. Then control is back at the interface...waiting for the timer to fire.
Tom Wright tawright915@gmail.com
-
you should try to get more information. do you use an ide? if yes, which one and does it support breakpoints?! if so, use them. make sure you see the line, where the timer is started, being executed. also print out the values of the timer before it get started. compare the code of the other two timers and so on. before starting any timer, you should print its values to make sure its set up correctly. try to debug it because, as you already said, noone will know where to start searching.
Question: can I make my timers avaliable in other classes...so that when the connection is closed, that class can start the timer, instead of me having to fire an event? thanks
Tom Wright tawright915@gmail.com
-
Question: can I make my timers avaliable in other classes...so that when the connection is closed, that class can start the timer, instead of me having to fire an event? thanks
Tom Wright tawright915@gmail.com
Sure you can, depending on how you've designed your classes :) If you want to make this timer available in other classes you have to have an instance of the class where the timer is in and provide a public interface (e.g. a property) for the other classes. Also check if your events are bound correctly and let them being fired by some function which definitely works (100%), to make sure that its a problem related with the timer or other code. You should try to fire the event at least once, to make sure that the timer itself works...
-
I have a socket app. I have an event that is fired when the connection is closed. This event is caught stops my other two timers, and enables a 3rd timer, sets the timer interval and starts it. But it never happens, it never drops in to the tick event method. I have two other timers that are started from an event...like when the connection is up, they work fine. But it does not work when the connection is closed. Not sure what code to post to help out as the event is in once class, the socket in another class, etc. Why would a timer not fire on the tick event? Thanks
Tom Wright tawright915@gmail.com
Are you using the System.Windows.Forms.Timer or the System.Threading.Timer? If you're using the tick event it looks like you're using the windows forms timer. If so, make sure you're using it in a class that inherits from
Form
, otherwise it won't work. TheThreading.Timer
is a better option in that case, you can set the interval and a callback function in its constructor. -
Are you using the System.Windows.Forms.Timer or the System.Threading.Timer? If you're using the tick event it looks like you're using the windows forms timer. If so, make sure you're using it in a class that inherits from
Form
, otherwise it won't work. TheThreading.Timer
is a better option in that case, you can set the interval and a callback function in its constructor.It's a forms timer. The timers are setup in my form class. My other timers are working fine.. They start and stop okay.....and they too are being started when the connection event is fired. Then the close event is fired I stop the first two timers and start a thrid timer. This will allow the connection to restart after a certain elasped time. However this third timer is never started. Even though I'm enabling, setting the time interval, and calling the start method. Thanks
Tom Wright tawright915@gmail.com
-
It's a forms timer. The timers are setup in my form class. My other timers are working fine.. They start and stop okay.....and they too are being started when the connection event is fired. Then the close event is fired I stop the first two timers and start a thrid timer. This will allow the connection to restart after a certain elasped time. However this third timer is never started. Even though I'm enabling, setting the time interval, and calling the start method. Thanks
Tom Wright tawright915@gmail.com