/// <summary> /// Subscribes the given object to changes in the active snapshot. /// </summary> /// <param name="snapshotObserver">The object to observe active snapshot changes.</param> public static void Subscribe(ISnapshotObserver snapshotObserver) { lock (SnapshotManager.ObserverLock) { if (!SnapshotManager.SnapshotObservers.Contains(snapshotObserver)) { SnapshotManager.SnapshotObservers.Add(snapshotObserver); snapshotObserver.Update(SnapshotManager.GetSnapshot(Snapshot.SnapshotRetrievalMode.FromActiveSnapshot, null)); } } }
/// <summary> /// Notify all observing objects of an active snapshot change. /// </summary> private static void NotifyObservers() { lock (SnapshotManager.ObserverLock) { Snapshot activeSnapshot = SnapshotManager.GetSnapshot(Snapshot.SnapshotRetrievalMode.FromActiveSnapshot, null); foreach (ISnapshotObserver observer in SnapshotManager.SnapshotObservers) { observer.Update(activeSnapshot); } } }