public static void AlarmStart(object o) { if (!Annunciators.Contains(o)) { Annunciators.Add(o); lock (Key) { if (!Alarm) { Alarm = true; Task.Run(() => { while (App.Live && Alarm) { using (var sound = new SoundPlayer(Properties.Resources.alarm)) { sound.PlaySync(); } } }); Task.Run(() => AlarmStatus?.Invoke(true)); } } } }
public static void AlarmStop(object o = null) { if (o != null) { Annunciators = Annunciators.Where(a => a != o).ToList(); if (Annunciators.Count > 0) { return; } } else { Annunciators = new List <object>(); } Alarm = false; Task.Run(() => AlarmStatus?.Invoke(false)); }