Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to pause and resume all Timers #3

Merged
merged 2 commits into from
Sep 8, 2018

Conversation

robinnorth
Copy link
Contributor

Hi there, thanks for your very useful library!

I have a need to be able to pause and resume all active timers in my project when an in-game pause menu is toggled, so I have extended TimerManager in the following way to support this:

  • Make TimerManager public to allow reference to current instance to be made
  • Add PauseAllTimers method to pause all Timer instances, following CancelAllTimers example
  • Add ResumeAllTimers method to resume all Timer instances, following CancelAllTimers example

I am aware from #1 that you'd kept TimerManager private deliberately, but I don't believe that this change should affect how it is used, i.e. instantiated automatically when the first new Timer instance is created. If, however, there is a better way to achieve pausing and resuming all timers at once, please let me know!

- Make `TimerManager` public to allow reference to current instance to be made
- Add `PauseAllTimers` method to pause all `Timer` instances, following `CancelAllTimers` example
- Add `ResumeAllTimers` method to resume all `Timer` instances, following `CancelAllTimers` example
@robinnorth
Copy link
Contributor Author

Turns out there was a better way to go about this, which is to follow the example of Timer.CancelAllRegisteredTimers! So, building on the previous implementation:

  • TimerManager is private once more
  • Timer.PauseAllRegisteredTimers method added, following Timer.CancelAllRegisteredTimers example
  • Timer.ResumeAllRegisteredTimers method added, following Timer.CancelAllRegisteredTimers example

@akbiggs
Copy link
Owner

akbiggs commented Sep 5, 2018

Oh god, I'm so sorry, I somehow had email notifications turned off! Reviewing now.

@akbiggs akbiggs merged commit e82b234 into akbiggs:master Sep 8, 2018
@robinnorth robinnorth deleted the feature/pause-resume-timers branch September 9, 2018 08:20
@robinnorth
Copy link
Contributor Author

Thanks for merging, @akbiggs!

@akbiggs
Copy link
Owner

akbiggs commented Sep 12, 2018

Sorry it took so long!!!!!!!!!!

@robinnorth
Copy link
Contributor Author

Not a problem, just happy to be able to contribute back to the project 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants