5
Answers

Global timer in c#

Mike McWhinney

Mike McWhinney

12y
5.7k
1
Hello,

I am writing a C# program that uses WinForms.  In the past, I have written programs that
measure voltages or other parameters from sensors and put them on a timer read. This worked well when needing to access this data in a single form. 

But now, I have a situation where I need to be able to have the timer running all of the time, regardless of what form I am on. There could be 4 or 5 forms in my program. 

I tried to put the timer in my MainForm, but that did not work very well, as I had to create another instance of MainForm, and that threw off the timers.

What I need is a method to be able to have a process or form running all of the time, and only create a single instance of it.

Can anyone point me to some information or code which explain a better method of what I'm trying to do?

Thanks

Answers (5)