Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class startTimer
- {
- Timer timer;
- GameClient Session;
- int timeLeft;
- public startTimer(GameClient Session, class Function)
- {
- this.Session = Session;
- int time = 1;
- timeLeft = time * 500;
- startTimer();
- }
- public void start()
- {
- TimerCallback timerFinished = timerDone;
- timer = new Timer(timerFinished, null, 500, Timeout.Infinite);
- }
- public void timerDone(object info)
- {
- try
- {
- timeLeft -= 500;
- #region Conditions
- if (Session == null)
- { stopTimer(); return; }
- if (timeLeft > 0)
- {
- // aqui se pone la clase a ejecutar
- new Function();
- timer.Change(500, Timeout.Infinite);
- return;
- }
- }
- catch { stopTimer(); }
- }
- public int getTime()
- {
- int minutesRemaining = timeLeft / 60000;
- return minutesRemaining;
- }
- public void stopTimer()
- {
- timer.Dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement