tags:

views:

194

answers:

2

I am trying to write a program that uses a timer, duration, start time and end time.

In this program it has three screens. When I click start timer on one screen, the other two screens with a timer will automatically update itself. What I currently have is one screen running the timer with the other two screens showing 00:00:00, while the first one is still running. I was wondering If anyone has a suggestion of how to link these three screens together such as if one minute has elapsed it will show 00:01:00 for all three screens instead of just 00:00:00 , 00:00:00 and 00:01:00.

I just need some sort of hint or an idea or what i should look up to solve this problem for myself.

The language I am using is C#

A: 

You are going to want to make sure that the timer is isolated from the GUI. I would suggest building a timer class and having it fire events that the windows will listen for (though you will probably want to limit it to firing the events every so often.) MSDN Tutorial on Events

ProgrammingPope
+8  A: 

You should use a delegate on your timer class. Each window should then handle the delegate event and update its display if needed.

Example:

Timer.TimeChange += form1.OnTimeChange;
Timer.TimeChange += form2.OnTimeChange;
Timer.TimeChange += form3.OnTimeChange;

where TimeChange is your timer delegate, and OnTimeChange are the form update method.

tinmaru