I use a System.Threading.Timer object, and I set its period:
// period of 1 second
var timer = new Timer(CallBack, null, 0, 1000);
...
Now I want to get the period of my timer, how can I do?
I use a System.Threading.Timer object, and I set its period:
// period of 1 second
var timer = new Timer(CallBack, null, 0, 1000);
...
Now I want to get the period of my timer, how can I do?
There is no supported way to do that. You have two options:
1) It's best to use System.Timers.Timer class, as it's more flexible, and safer to use in case of multi threaded use. If you want to know more about timers, and comparison between System.Windows.Forms.Timer, System.Timers.Timer and System.Threading.Timer, please read MSDN article about this subject.
2) Use reflection to access private member holding the period value. There are plenty of nice articles on how to do this, and you can use ILSpy to see which field you need to read. (it's timer.m_timer.m_timer.m_period in .NET 4.0, it may be the same in other versions too)
You don't. That is to say System.Threading.Timer does not support getting the period (or any other members as far as I know). The only way to approximately determine the period would be to time it yourself.
You can't using System.Threading.Timer but you can if you use System.Timers.Timer or System.Windows.Forms.Timer, there you have Timer.Interval property that you can check. You can further refer to this link to see the differences of this two implementations.