Ignore:
Timestamp:
01/15/09 14:53:13 (12 years ago)
Author:
msteinbi
Message:

Implementing Lifecycle Management (#453)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.Core/LifecycleManager.cs

    r1088 r1133  
    3333      new Timer();
    3434
     35    private static event EventHandler OnServerHeartbeat;
     36    private static event EventHandler OnStartup;
     37    private static event EventHandler OnShutdown;
    3538    #region ILifecycleManager Members
    36     public event EventHandler OnServerHeartbeat;
    3739
    38     public LifecycleManager() {
    39       timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
     40    public void RegisterHeartbeat(EventHandler handler) {
     41      OnServerHeartbeat += handler;
     42    }
     43
     44    public void RegisterStartup(EventHandler handler) {
     45      OnStartup += handler;
     46    }
     47
     48    public void RegisterShutdown(EventHandler handler) {
     49      OnShutdown += handler;
    4050    }
    4151
    4252    public void Init() {
    4353      timer.Interval = new TimeSpan(0, 0, 10).TotalMilliseconds; // TODO: global constant needed
     54      timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
    4455      timer.Start();
     56
     57      if (OnStartup != null)
     58        OnStartup(this, null);
    4559    }
    4660
     
    5670    public void Shutdown() {
    5771      ServiceLocator.GetTransactionManager().UpdateDB();
     72
     73      if (OnShutdown != null)
     74        OnShutdown(this, null);
    5875    }
    5976
Note: See TracChangeset for help on using the changeset viewer.