Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RecurringJob : IJob, IRegisteredObject
- {
- private static readonly object currentLock = new object();
- private static bool active = false;
- private static bool CanContinue {
- get {
- lock(currentLock){
- return !active;
- }
- }
- }
- public RecurringJob()
- {
- //code to setup job
- }
- public void Execute()
- {
- if (CanContinue)
- {
- active = true;
- //do work here
- active = false;
- }
- }
- public void Stop(bool immediate)
- {
- //code to handle application stopping graefully
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement